diff options
162 files changed, 1374 insertions, 1223 deletions
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg new file mode 100644 index 000000000000..f5bd945cf401 --- /dev/null +++ b/PREUPLOAD.cfg @@ -0,0 +1,7 @@ +[Hook Scripts] +checkstyle_hook = ../../development/tools/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT} + -fw core/java/android/animation/ + core/java/android/text/ + core/java/android/view/ + core/java/android/transition/ + core/java/android/widget/ diff --git a/apct-tests/perftests/utils/src/android/perftests/utils/PerfStatusReporter.java b/apct-tests/perftests/utils/src/android/perftests/utils/PerfStatusReporter.java index 3933b57753dc..64b0bf589a1b 100644 --- a/apct-tests/perftests/utils/src/android/perftests/utils/PerfStatusReporter.java +++ b/apct-tests/perftests/utils/src/android/perftests/utils/PerfStatusReporter.java @@ -18,8 +18,9 @@ package android.perftests.utils; import android.support.test.InstrumentationRegistry; -import org.junit.rules.TestWatcher; +import org.junit.rules.TestRule; import org.junit.runner.Description; +import org.junit.runners.model.Statement; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; @@ -47,7 +48,7 @@ import static junit.framework.Assert.assertTrue; * name when using parameterization. */ -public class PerfStatusReporter extends TestWatcher { +public class PerfStatusReporter implements TestRule { private final BenchmarkState mState = new BenchmarkState(); public BenchmarkState getBenchmarkState() { @@ -55,33 +56,39 @@ public class PerfStatusReporter extends TestWatcher { } @Override - protected void succeeded(Description description) { - String invokeMethodName = description.getMethodName(); - // validate and simplify the function name. - // First, remove the "test" prefix which normally comes from CTS test. - // Then make sure the [subTestName] is valid, not just numbers like [0]. - if (invokeMethodName.startsWith("test")) { - assertTrue("The test name " + invokeMethodName + " is too short", - invokeMethodName.length() > 5); - invokeMethodName = invokeMethodName.substring(4, 5).toLowerCase() - + invokeMethodName.substring(5); - } + public Statement apply(Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + String invokeMethodName = description.getMethodName(); + // validate and simplify the function name. + // First, remove the "test" prefix which normally comes from CTS test. + // Then make sure the [subTestName] is valid, not just numbers like [0]. + if (invokeMethodName.startsWith("test")) { + assertTrue("The test name " + invokeMethodName + " is too short", + invokeMethodName.length() > 5); + invokeMethodName = invokeMethodName.substring(4, 5).toLowerCase() + + invokeMethodName.substring(5); + } - int index = invokeMethodName.lastIndexOf('['); - if (index > 0) { - boolean allDigits = true; - for (int i = index + 1; i < invokeMethodName.length() - 1; i++) { - if (!Character.isDigit(invokeMethodName.charAt(i))) { - allDigits = false; - break; + int index = invokeMethodName.lastIndexOf('['); + if (index > 0) { + boolean allDigits = true; + for (int i = index + 1; i < invokeMethodName.length() - 1; i++) { + if (!Character.isDigit(invokeMethodName.charAt(i))) { + allDigits = false; + break; + } + } + assertFalse("The name in [] can't contain only digits for " + invokeMethodName, + allDigits); } - } - assertFalse("The name in [] can't contain only digits for " + invokeMethodName, - allDigits); - } - mState.sendFullStatusReport(InstrumentationRegistry.getInstrumentation(), - invokeMethodName); - } + base.evaluate(); + mState.sendFullStatusReport(InstrumentationRegistry.getInstrumentation(), + invokeMethodName); + } + }; + } } diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp index 6d30f0d0ce34..ab6adfb9475f 100644 --- a/cmds/idmap/scan.cpp +++ b/cmds/idmap/scan.cpp @@ -1,5 +1,6 @@ #include <dirent.h> #include <inttypes.h> +#include <sys/file.h> #include <sys/stat.h> #include "idmap.h" @@ -35,16 +36,31 @@ namespace { bool writePackagesList(const char *filename, const SortedVector<Overlay>& overlayVector) { - FILE* fout = fopen(filename, "w"); + // the file is opened for appending so that it doesn't get truncated + // before we can guarantee mutual exclusion via the flock + FILE* fout = fopen(filename, "a"); if (fout == NULL) { return false; } + if (TEMP_FAILURE_RETRY(flock(fileno(fout), LOCK_EX)) != 0) { + fclose(fout); + return false; + } + + if (TEMP_FAILURE_RETRY(ftruncate(fileno(fout), 0)) != 0) { + TEMP_FAILURE_RETRY(flock(fileno(fout), LOCK_UN)); + fclose(fout); + return false; + } + for (size_t i = 0; i < overlayVector.size(); ++i) { const Overlay& overlay = overlayVector[i]; fprintf(fout, "%s %s\n", overlay.apk_path.string(), overlay.idmap_path.string()); } + TEMP_FAILURE_RETRY(fflush(fout)); + TEMP_FAILURE_RETRY(flock(fileno(fout), LOCK_UN)); fclose(fout); // Make file world readable since Zygote (running as root) will read @@ -171,9 +187,6 @@ int idmap_scan(const char *target_package_name, const char *target_apk_path, { String8 filename = String8(idmap_dir); filename.appendPath("overlays.list"); - if (unlink(filename.string()) != 0 && errno != ENOENT) { - return EXIT_FAILURE; - } SortedVector<Overlay> overlayVector; const size_t N = overlay_dirs->size(); diff --git a/core/java/android/animation/KeyframeSet.java b/core/java/android/animation/KeyframeSet.java index fd0bf0bc4727..116d0631bd7d 100644 --- a/core/java/android/animation/KeyframeSet.java +++ b/core/java/android/animation/KeyframeSet.java @@ -16,15 +16,15 @@ package android.animation; -import java.util.Arrays; -import java.util.List; - -import android.animation.Keyframe.IntKeyframe; import android.animation.Keyframe.FloatKeyframe; +import android.animation.Keyframe.IntKeyframe; import android.animation.Keyframe.ObjectKeyframe; import android.graphics.Path; import android.util.Log; +import java.util.Arrays; +import java.util.List; + /** * This class holds a collection of Keyframe objects and is called by ValueAnimator to calculate * values between those keyframes for a given animation. The class internal to the animation diff --git a/core/java/android/transition/ChangeBounds.java b/core/java/android/transition/ChangeBounds.java index a95da976d115..b6d8aa449533 100644 --- a/core/java/android/transition/ChangeBounds.java +++ b/core/java/android/transition/ChangeBounds.java @@ -16,19 +16,18 @@ package android.transition; -import android.animation.AnimatorSet; -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.PointF; - import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.RectEvaluator; +import android.content.Context; +import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Path; +import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; diff --git a/core/java/android/transition/ChangeScroll.java b/core/java/android/transition/ChangeScroll.java index e09268553a18..8a3fd1c34daa 100644 --- a/core/java/android/transition/ChangeScroll.java +++ b/core/java/android/transition/ChangeScroll.java @@ -19,8 +19,6 @@ package android.transition; import android.animation.Animator; import android.animation.ObjectAnimator; import android.content.Context; -import android.transition.Transition; -import android.transition.TransitionValues; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; diff --git a/core/java/android/transition/ChangeTransform.java b/core/java/android/transition/ChangeTransform.java index 974912167205..4b0b065ad6b1 100644 --- a/core/java/android/transition/ChangeTransform.java +++ b/core/java/android/transition/ChangeTransform.java @@ -30,6 +30,7 @@ import android.util.Property; import android.view.GhostView; import android.view.View; import android.view.ViewGroup; + import com.android.internal.R; /** diff --git a/core/java/android/transition/Explode.java b/core/java/android/transition/Explode.java index 3445ef2fbbaa..5f078ca53fec 100644 --- a/core/java/android/transition/Explode.java +++ b/core/java/android/transition/Explode.java @@ -15,8 +15,6 @@ */ package android.transition; -import com.android.internal.R; - import android.animation.Animator; import android.animation.TimeInterpolator; import android.content.Context; @@ -26,6 +24,8 @@ import android.view.View; import android.view.ViewGroup; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; + +import com.android.internal.R; /** * This transition tracks changes to the visibility of target views in the * start and end scenes and moves views in or out from the edges of the diff --git a/core/java/android/transition/PatternPathMotion.java b/core/java/android/transition/PatternPathMotion.java index f23863f8851f..7a2c191be0dd 100644 --- a/core/java/android/transition/PatternPathMotion.java +++ b/core/java/android/transition/PatternPathMotion.java @@ -15,8 +15,6 @@ */ package android.transition; -import com.android.internal.R; - import android.content.Context; import android.content.res.TypedArray; import android.graphics.Matrix; @@ -25,6 +23,8 @@ import android.graphics.PathMeasure; import android.util.AttributeSet; import android.util.PathParser; +import com.android.internal.R; + /** * A PathMotion that takes a Path pattern and applies it to the separation between two points. * The starting point of the Path will be moved to the origin and the end point will be scaled diff --git a/core/java/android/transition/Slide.java b/core/java/android/transition/Slide.java index 2645f861a5ad..9cf321014ff8 100644 --- a/core/java/android/transition/Slide.java +++ b/core/java/android/transition/Slide.java @@ -26,6 +26,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; + import com.android.internal.R; import java.lang.annotation.Retention; diff --git a/core/java/android/transition/TransitionInflater.java b/core/java/android/transition/TransitionInflater.java index cbf76bc3dc4b..4c5a71764728 100644 --- a/core/java/android/transition/TransitionInflater.java +++ b/core/java/android/transition/TransitionInflater.java @@ -17,11 +17,6 @@ package android.transition; import android.annotation.TransitionRes; -import com.android.internal.R; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; @@ -32,6 +27,11 @@ import android.util.Xml; import android.view.InflateException; import android.view.ViewGroup; +import com.android.internal.R; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; diff --git a/core/java/android/transition/TranslationAnimationCreator.java b/core/java/android/transition/TranslationAnimationCreator.java index b07f3f87b1e6..ae76e6254f6b 100644 --- a/core/java/android/transition/TranslationAnimationCreator.java +++ b/core/java/android/transition/TranslationAnimationCreator.java @@ -15,8 +15,6 @@ */ package android.transition; -import com.android.internal.R; - import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; @@ -25,6 +23,8 @@ import android.graphics.Path; import android.transition.Transition.TransitionListener; import android.view.View; +import com.android.internal.R; + /** * This class is used by Slide and Explode to create an animator that goes from the start * position to the end position. It takes into account the canceled position so that it diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 85a4bf9d9e8f..3beb00fc8d9e 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -16,11 +16,11 @@ package android.view; +import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE; + import android.annotation.IntDef; import android.annotation.RequiresPermission; -import android.content.Context; import android.content.res.CompatibilityInfo; -import android.content.res.Resources; import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.Rect; @@ -36,8 +36,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Arrays; -import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE; - /** * Provides information about the size and density of a logical display. * <p> diff --git a/core/java/android/view/DisplayEventReceiver.java b/core/java/android/view/DisplayEventReceiver.java index 4393992b3245..67cdfc53fb39 100644 --- a/core/java/android/view/DisplayEventReceiver.java +++ b/core/java/android/view/DisplayEventReceiver.java @@ -16,13 +16,13 @@ package android.view; -import dalvik.annotation.optimization.FastNative; -import dalvik.system.CloseGuard; - import android.os.Looper; import android.os.MessageQueue; import android.util.Log; +import dalvik.annotation.optimization.FastNative; +import dalvik.system.CloseGuard; + import java.lang.ref.WeakReference; /** diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java index bc40849a47bc..1aef6ec0f302 100644 --- a/core/java/android/view/DisplayInfo.java +++ b/core/java/android/view/DisplayInfo.java @@ -23,10 +23,10 @@ import android.os.Parcelable; import android.util.ArraySet; import android.util.DisplayMetrics; -import java.util.Arrays; - import libcore.util.Objects; +import java.util.Arrays; + /** * Describes the characteristics of a particular logical display. * @hide diff --git a/core/java/android/view/FallbackEventHandler.java b/core/java/android/view/FallbackEventHandler.java index dd68d8966eb8..8e00d6da7ea7 100644 --- a/core/java/android/view/FallbackEventHandler.java +++ b/core/java/android/view/FallbackEventHandler.java @@ -24,4 +24,3 @@ public interface FallbackEventHandler { public void preDispatchKeyEvent(KeyEvent event); public boolean dispatchKeyEvent(KeyEvent event); } - diff --git a/core/java/android/view/FrameMetrics.java b/core/java/android/view/FrameMetrics.java index 2b938d0df7eb..800a63f7da07 100644 --- a/core/java/android/view/FrameMetrics.java +++ b/core/java/android/view/FrameMetrics.java @@ -17,7 +17,6 @@ package android.view; import android.annotation.IntDef; -import android.view.Window; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/core/java/android/view/FrameMetricsObserver.java b/core/java/android/view/FrameMetricsObserver.java index 63313578cffe..9e81de0e09bb 100644 --- a/core/java/android/view/FrameMetricsObserver.java +++ b/core/java/android/view/FrameMetricsObserver.java @@ -17,15 +17,12 @@ package android.view; import android.annotation.NonNull; -import android.util.Log; import android.os.Looper; import android.os.MessageQueue; import com.android.internal.util.VirtualRefBasePtr; -import java.lang.NullPointerException; import java.lang.ref.WeakReference; -import java.lang.SuppressWarnings; /** * Provides streaming access to frame stats information from the rendering diff --git a/core/java/android/view/HandlerActionQueue.java b/core/java/android/view/HandlerActionQueue.java index 4758a3408dc2..d016a7444082 100644 --- a/core/java/android/view/HandlerActionQueue.java +++ b/core/java/android/view/HandlerActionQueue.java @@ -16,11 +16,9 @@ package android.view; -import com.android.internal.util.GrowingArrayUtils; - import android.os.Handler; -import java.util.ArrayList; +import com.android.internal.util.GrowingArrayUtils; /** * Class used to enqueue pending work from Views when no Handler is attached. diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java index f8796c31fe93..55f64d9f6664 100644 --- a/core/java/android/view/InputDevice.java +++ b/core/java/android/view/InputDevice.java @@ -19,10 +19,10 @@ package android.view; import android.content.Context; import android.hardware.input.InputDeviceIdentifier; import android.hardware.input.InputManager; +import android.os.NullVibrator; import android.os.Parcel; import android.os.Parcelable; import android.os.Vibrator; -import android.os.NullVibrator; import java.util.ArrayList; import java.util.List; diff --git a/core/java/android/view/InputEventReceiver.java b/core/java/android/view/InputEventReceiver.java index 91ef50d76180..20ab539f52d2 100644 --- a/core/java/android/view/InputEventReceiver.java +++ b/core/java/android/view/InputEventReceiver.java @@ -16,13 +16,13 @@ package android.view; -import dalvik.system.CloseGuard; - import android.os.Looper; import android.os.MessageQueue; import android.util.Log; import android.util.SparseIntArray; +import dalvik.system.CloseGuard; + import java.lang.ref.WeakReference; /** diff --git a/core/java/android/view/InputEventSender.java b/core/java/android/view/InputEventSender.java index 304ea3f8bd2b..b25fb65b654c 100644 --- a/core/java/android/view/InputEventSender.java +++ b/core/java/android/view/InputEventSender.java @@ -16,12 +16,12 @@ package android.view; -import dalvik.system.CloseGuard; - import android.os.Looper; import android.os.MessageQueue; import android.util.Log; +import dalvik.system.CloseGuard; + import java.lang.ref.WeakReference; /** diff --git a/core/java/android/view/InputFilter.java b/core/java/android/view/InputFilter.java index 4aba30ca483e..d0dab4000fff 100644 --- a/core/java/android/view/InputFilter.java +++ b/core/java/android/view/InputFilter.java @@ -20,12 +20,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.RemoteException; -import android.view.IInputFilter; -import android.view.InputEvent; -import android.view.InputEventConsistencyVerifier; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.WindowManagerPolicy; /** * Filters input events before they are dispatched to the system. diff --git a/core/java/android/view/InputQueue.java b/core/java/android/view/InputQueue.java index aebc60152bf0..582ae79a743f 100644 --- a/core/java/android/view/InputQueue.java +++ b/core/java/android/view/InputQueue.java @@ -16,13 +16,13 @@ package android.view; -import dalvik.system.CloseGuard; - import android.os.Looper; import android.os.MessageQueue; +import android.util.LongSparseArray; import android.util.Pools.Pool; import android.util.Pools.SimplePool; -import android.util.LongSparseArray; + +import dalvik.system.CloseGuard; import java.lang.ref.WeakReference; diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java index c8b89e7ac607..88f2d3460346 100644 --- a/core/java/android/view/KeyCharacterMap.java +++ b/core/java/android/view/KeyCharacterMap.java @@ -16,14 +16,13 @@ package android.view; +import android.hardware.input.InputManager; import android.os.Parcel; import android.os.Parcelable; import android.text.method.MetaKeyKeyListener; import android.util.AndroidRuntimeException; import android.util.SparseIntArray; -import android.hardware.input.InputManager; -import java.lang.Character; import java.text.Normalizer; /** diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index b73acdaf6d8b..5d8f336ef193 100644 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -21,7 +21,6 @@ import android.os.Parcelable; import android.text.method.MetaKeyKeyListener; import android.util.Log; import android.util.SparseIntArray; -import android.view.KeyCharacterMap; import android.view.KeyCharacterMap.KeyData; /** diff --git a/core/java/android/view/KeyboardShortcutGroup.java b/core/java/android/view/KeyboardShortcutGroup.java index 57d07c0d0eac..78f0b30e7e20 100644 --- a/core/java/android/view/KeyboardShortcutGroup.java +++ b/core/java/android/view/KeyboardShortcutGroup.java @@ -15,6 +15,8 @@ */ package android.view; +import static com.android.internal.util.Preconditions.checkNotNull; + import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Parcel; @@ -24,8 +26,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static com.android.internal.util.Preconditions.checkNotNull; - /** * A group of {@link KeyboardShortcutInfo}. */ diff --git a/core/java/android/view/KeyboardShortcutInfo.java b/core/java/android/view/KeyboardShortcutInfo.java index a9f2699a6bb1..c934a4e31f98 100644 --- a/core/java/android/view/KeyboardShortcutInfo.java +++ b/core/java/android/view/KeyboardShortcutInfo.java @@ -15,14 +15,15 @@ */ package android.view; +import static com.android.internal.util.Preconditions.checkArgument; + +import static java.lang.Character.MIN_VALUE; + import android.annotation.Nullable; import android.graphics.drawable.Icon; import android.os.Parcel; import android.os.Parcelable; -import static com.android.internal.util.Preconditions.checkArgument; -import static java.lang.Character.MIN_VALUE; - /** * Information about a Keyboard Shortcut. */ diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index 914bd5684b4a..e3ac40c5da4e 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -16,11 +16,6 @@ package android.view; -import com.android.internal.R; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - import android.annotation.LayoutRes; import android.annotation.Nullable; import android.content.Context; @@ -37,6 +32,11 @@ import android.util.TypedValue; import android.util.Xml; import android.widget.FrameLayout; +import com.android.internal.R; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + import java.io.IOException; import java.lang.reflect.Constructor; import java.util.HashMap; @@ -51,20 +51,20 @@ import java.util.HashMap; * * <pre>LayoutInflater inflater = (LayoutInflater)context.getSystemService * (Context.LAYOUT_INFLATER_SERVICE);</pre> - * + * * <p> * To create a new LayoutInflater with an additional {@link Factory} for your * own views, you can use {@link #cloneInContext} to clone an existing * ViewFactory, and then call {@link #setFactory} on it to include your * Factory. - * + * * <p> * For performance reasons, view inflation relies heavily on pre-processing of * XML files that is done at build time. Therefore, it is not currently possible * to use LayoutInflater with an XmlPullParser over a plain XML file at runtime; * it only works with an XmlPullParser returned from a compiled resource * (R.<em>something</em> file.) - * + * * @see Context#getSystemService */ public abstract class LayoutInflater { @@ -95,7 +95,7 @@ public abstract class LayoutInflater { private static final HashMap<String, Constructor<? extends View>> sConstructorMap = new HashMap<String, Constructor<? extends View>>(); - + private HashMap<String, Boolean> mFilterMap; private TypedValue mTempValue; @@ -114,36 +114,36 @@ public abstract class LayoutInflater { /** * Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed * to be inflated. - * + * */ public interface Filter { /** - * Hook to allow clients of the LayoutInflater to restrict the set of Views + * Hook to allow clients of the LayoutInflater to restrict the set of Views * that are allowed to be inflated. - * + * * @param clazz The class object for the View that is about to be inflated - * + * * @return True if this class is allowed to be inflated, or false otherwise */ @SuppressWarnings("unchecked") boolean onLoadClass(Class clazz); } - + public interface Factory { /** * Hook you can supply that is called when inflating from a LayoutInflater. * You can use this to customize the tag names available in your XML * layout files. - * + * * <p> * Note that it is good practice to prefix these custom names with your * package (i.e., com.coolcompany.apps) to avoid conflicts with system * names. - * + * * @param name Tag name to be inflated. * @param context The context the view is being created in. * @param attrs Inflation attributes as specified in XML file. - * + * * @return View Newly created view. Return null for the default * behavior. */ @@ -171,14 +171,14 @@ public abstract class LayoutInflater { private static class FactoryMerger implements Factory2 { private final Factory mF1, mF2; private final Factory2 mF12, mF22; - + FactoryMerger(Factory f1, Factory2 f12, Factory f2, Factory2 f22) { mF1 = f1; mF2 = f2; mF12 = f12; mF22 = f22; } - + public View onCreateView(String name, Context context, AttributeSet attrs) { View v = mF1.onCreateView(name, context, attrs); if (v != null) return v; @@ -193,13 +193,13 @@ public abstract class LayoutInflater { : mF2.onCreateView(name, context, attrs); } } - + /** * Create a new LayoutInflater instance associated with a particular Context. * Applications will almost always want to use * {@link Context#getSystemService Context.getSystemService()} to retrieve * the standard {@link Context#LAYOUT_INFLATER_SERVICE Context.INFLATER_SERVICE}. - * + * * @param context The Context in which this LayoutInflater will create its * Views; most importantly, this supplies the theme from which the default * values for their attributes are retrieved. @@ -212,7 +212,7 @@ public abstract class LayoutInflater { * Create a new LayoutInflater instance that is a copy of an existing * LayoutInflater, optionally with its Context changed. For use in * implementing {@link #cloneInContext}. - * + * * @param original The original LayoutInflater to copy. * @param newContext The new Context to use. */ @@ -223,7 +223,7 @@ public abstract class LayoutInflater { mPrivateFactory = original.mPrivateFactory; setFilter(original.mFilter); } - + /** * Obtains the LayoutInflater from the given context. */ @@ -241,15 +241,15 @@ public abstract class LayoutInflater { * pointing to a different Context than the original. This is used by * {@link ContextThemeWrapper} to create a new LayoutInflater to go along * with the new Context theme. - * + * * @param newContext The new Context to associate with the new LayoutInflater. * May be the same as the original Context if desired. - * + * * @return Returns a brand spanking new LayoutInflater object associated with * the given Context. */ public abstract LayoutInflater cloneInContext(Context newContext); - + /** * Return the context we are running in, for access to resources, class * loader, etc. @@ -285,7 +285,7 @@ public abstract class LayoutInflater { * called on each element name as the xml is parsed. If the factory returns * a View, that is added to the hierarchy. If it returns null, the next * factory default {@link #onCreateView} method is called. - * + * * <p>If you have an existing * LayoutInflater and want to add your own factory to it, use * {@link #cloneInContext} to clone the existing instance and then you @@ -345,13 +345,13 @@ public abstract class LayoutInflater { public Filter getFilter() { return mFilter; } - + /** * Sets the {@link Filter} to by this LayoutInflater. If a view is attempted to be inflated * which is not allowed by the {@link Filter}, the {@link #inflate(int, ViewGroup)} call will * throw an {@link InflateException}. This filter will replace any previous filter set on this * LayoutInflater. - * + * * @param filter The Filter which restricts the set of Views that are allowed to be inflated. * This filter will replace any previous filter set on this LayoutInflater. */ @@ -365,7 +365,7 @@ public abstract class LayoutInflater { /** * Inflate a new view hierarchy from the specified xml resource. Throws * {@link InflateException} if there is an error. - * + * * @param resource ID for an XML layout resource to load (e.g., * <code>R.layout.main_page</code>) * @param root Optional view to be the parent of the generated hierarchy. @@ -385,7 +385,7 @@ public abstract class LayoutInflater { * reasons, view inflation relies heavily on pre-processing of XML files * that is done at build time. Therefore, it is not currently possible to * use LayoutInflater with an XmlPullParser over a plain XML file at runtime. - * + * * @param parser XML dom node containing the description of the view * hierarchy. * @param root Optional view to be the parent of the generated hierarchy. @@ -400,7 +400,7 @@ public abstract class LayoutInflater { /** * Inflate a new view hierarchy from the specified xml resource. Throws * {@link InflateException} if there is an error. - * + * * @param resource ID for an XML layout resource to load (e.g., * <code>R.layout.main_page</code>) * @param root Optional view to be the parent of the generated hierarchy (if @@ -437,7 +437,7 @@ public abstract class LayoutInflater { * reasons, view inflation relies heavily on pre-processing of XML files * that is done at build time. Therefore, it is not currently possible to * use LayoutInflater with an XmlPullParser over a plain XML file at runtime. - * + * * @param parser XML dom node containing the description of the view * hierarchy. * @param root Optional view to be the parent of the generated hierarchy (if @@ -475,7 +475,7 @@ public abstract class LayoutInflater { } final String name = parser.getName(); - + if (DEBUG) { System.out.println("**************************"); System.out.println("Creating root view: " @@ -579,17 +579,17 @@ public abstract class LayoutInflater { * Low-level function for instantiating a view by name. This attempts to * instantiate a view class of the given <var>name</var> found in this * LayoutInflater's ClassLoader. - * + * * <p> * There are two things that can happen in an error case: either the * exception describing the error will be thrown, or a null will be * returned. You must deal with both possibilities -- the former will happen * the first time createView() is called for a class of a particular name, * the latter every time there-after for that class name. - * + * * @param name The full name of the class to be instantiated. * @param attrs The XML attributes supplied for this instance. - * + * * @return View The newly instantiated view, or null. */ public final View createView(String name, String prefix, AttributeSet attrs) @@ -608,7 +608,7 @@ public abstract class LayoutInflater { // Class not found in the cache, see if it's real, and try to add it clazz = mContext.getClassLoader().loadClass( prefix != null ? (prefix + name) : name).asSubclass(View.class); - + if (mFilter != null && clazz != null) { boolean allowed = mFilter.onLoadClass(clazz); if (!allowed) { @@ -627,7 +627,7 @@ public abstract class LayoutInflater { // New class -- remember whether it is allowed clazz = mContext.getClassLoader().loadClass( prefix != null ? (prefix + name) : name).asSubclass(View.class); - + boolean allowed = clazz != null && mFilter.onLoadClass(clazz); mFilterMap.put(name, allowed); if (!allowed) { @@ -689,10 +689,10 @@ public abstract class LayoutInflater { * given the xml element name. Override it to handle custom view objects. If * you override this in your subclass be sure to call through to * super.onCreateView(name) for names you do not recognize. - * + * * @param name The fully qualified class name of the View to be create. * @param attrs An AttributeSet of attributes to apply to the View. - * + * * @return View The View created. */ protected View onCreateView(String name, AttributeSet attrs) @@ -842,7 +842,7 @@ public abstract class LayoutInflater { } final String name = parser.getName(); - + if (TAG_REQUEST_FOCUS.equals(name)) { parseRequestFocus(parser, parent); } else if (TAG_TAG.equals(name)) { diff --git a/core/java/android/view/MenuInflater.java b/core/java/android/view/MenuInflater.java index 1c67ba74184e..73ea9ee31bce 100644 --- a/core/java/android/view/MenuInflater.java +++ b/core/java/android/view/MenuInflater.java @@ -16,11 +16,6 @@ package android.view; -import com.android.internal.view.menu.MenuItemImpl; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - import android.annotation.MenuRes; import android.app.Activity; import android.content.Context; @@ -31,6 +26,11 @@ import android.util.AttributeSet; import android.util.Log; import android.util.Xml; +import com.android.internal.view.menu.MenuItemImpl; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -49,15 +49,15 @@ public class MenuInflater { /** Menu tag name in XML. */ private static final String XML_MENU = "menu"; - + /** Group tag name in XML. */ private static final String XML_GROUP = "group"; - + /** Item tag name in XML. */ private static final String XML_ITEM = "item"; private static final int NO_ID = 0; - + private static final Class<?>[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class[] {Context.class}; private static final Class<?>[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = ACTION_VIEW_CONSTRUCTOR_SIGNATURE; @@ -71,7 +71,7 @@ public class MenuInflater { /** * Constructs a menu inflater. - * + * * @see Activity#getMenuInflater() */ public MenuInflater(Context context) { @@ -96,7 +96,7 @@ public class MenuInflater { /** * Inflate a menu hierarchy from the specified XML resource. Throws * {@link InflateException} if there is an error. - * + * * @param menuRes Resource ID for an XML layout resource to load (e.g., * <code>R.menu.main_activity</code>) * @param menu The Menu to inflate into. The items and submenus will be @@ -107,7 +107,7 @@ public class MenuInflater { try { parser = mContext.getResources().getLayout(menuRes); AttributeSet attrs = Xml.asAttributeSet(parser); - + parseMenu(parser, attrs, menu); } catch (XmlPullParserException e) { throw new InflateException("Error inflating menu XML", e); @@ -140,12 +140,12 @@ public class MenuInflater { eventType = parser.next(); break; } - + throw new RuntimeException("Expecting menu, got " + tagName); } eventType = parser.next(); } while (eventType != XmlPullParser.END_DOCUMENT); - + boolean reachedEndOfMenu = false; while (!reachedEndOfMenu) { switch (eventType) { @@ -153,7 +153,7 @@ public class MenuInflater { if (lookingForEndOfUnknownTag) { break; } - + tagName = parser.getName(); if (tagName.equals(XML_GROUP)) { menuState.readGroup(attrs); @@ -171,7 +171,7 @@ public class MenuInflater { unknownTagName = tagName; } break; - + case XmlPullParser.END_TAG: tagName = parser.getName(); if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) { @@ -194,11 +194,11 @@ public class MenuInflater { reachedEndOfMenu = true; } break; - + case XmlPullParser.END_DOCUMENT: throw new RuntimeException("Unexpected end of document"); } - + eventType = parser.next(); } } @@ -229,10 +229,10 @@ public class MenuInflater { private static class InflatedOnMenuItemClickListener implements MenuItem.OnMenuItemClickListener { private static final Class<?>[] PARAM_TYPES = new Class[] { MenuItem.class }; - + private Object mRealOwner; private Method mMethod; - + public InflatedOnMenuItemClickListener(Object realOwner, String methodName) { mRealOwner = realOwner; Class<?> c = realOwner.getClass(); @@ -246,7 +246,7 @@ public class MenuInflater { throw ex; } } - + public boolean onMenuItemClick(MenuItem item) { try { if (mMethod.getReturnType() == Boolean.TYPE) { @@ -277,7 +277,7 @@ public class MenuInflater { } return owner; } - + /** * State for the current menu. * <p> @@ -316,7 +316,7 @@ public class MenuInflater { private boolean itemChecked; private boolean itemVisible; private boolean itemEnabled; - + /** * Sync to attrs.xml enum, values in MenuItem: * - 0: never @@ -331,7 +331,7 @@ public class MenuInflater { private String itemActionProviderClassName; private String itemListenerMethodName; - + private ActionProvider itemActionProvider; private static final int defaultGroupId = NO_ID; @@ -342,13 +342,13 @@ public class MenuInflater { private static final boolean defaultItemChecked = false; private static final boolean defaultItemVisible = true; private static final boolean defaultItemEnabled = true; - + public MenuState(final Menu menu) { this.menu = menu; - + resetGroup(); } - + public void resetGroup() { groupId = defaultGroupId; groupCategory = defaultItemCategory; @@ -364,7 +364,7 @@ public class MenuInflater { public void readGroup(AttributeSet attrs) { TypedArray a = mContext.obtainStyledAttributes(attrs, com.android.internal.R.styleable.MenuGroup); - + groupId = a.getResourceId(com.android.internal.R.styleable.MenuGroup_id, defaultGroupId); groupCategory = a.getInt(com.android.internal.R.styleable.MenuGroup_menuCategory, defaultItemCategory); groupOrder = a.getInt(com.android.internal.R.styleable.MenuGroup_orderInCategory, defaultItemOrder); @@ -374,7 +374,7 @@ public class MenuInflater { a.recycle(); } - + /** * Called when the parser is pointing to an item tag. */ @@ -436,7 +436,7 @@ public class MenuInflater { return shortcutString.charAt(0); } } - + private void setItem(MenuItem item) { item.setChecked(itemChecked) .setVisible(itemVisible) @@ -446,11 +446,11 @@ public class MenuInflater { .setIcon(itemIconResId) .setAlphabeticShortcut(itemAlphabeticShortcut) .setNumericShortcut(itemNumericShortcut); - + if (itemShowAsAction >= 0) { item.setShowAsAction(itemShowAsAction); } - + if (itemListenerMethodName != null) { if (mContext.isRestricted()) { throw new IllegalStateException("The android:onClick attribute cannot " @@ -494,14 +494,14 @@ public class MenuInflater { setItem(item); return item; } - + public SubMenu addSubMenuItem() { itemAdded = true; SubMenu subMenu = menu.addSubMenu(groupId, itemId, itemCategoryOrder, itemTitle); setItem(subMenu.getItem()); return subMenu; } - + public boolean hasAddedItem() { return itemAdded; } diff --git a/core/java/android/view/PointerIcon.java b/core/java/android/view/PointerIcon.java index fc79f53b744b..998fd0195a98 100644 --- a/core/java/android/view/PointerIcon.java +++ b/core/java/android/view/PointerIcon.java @@ -17,9 +17,6 @@ package android.view; import android.annotation.NonNull; -import android.util.SparseArray; -import com.android.internal.util.XmlUtils; - import android.annotation.XmlRes; import android.content.Context; import android.content.res.Resources; @@ -32,6 +29,9 @@ import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; +import android.util.SparseArray; + +import com.android.internal.util.XmlUtils; /** * Represents an icon that can be used as a mouse pointer. diff --git a/core/java/android/view/RemotableViewMethod.java b/core/java/android/view/RemotableViewMethod.java index e5cae84942f9..03aed9a53925 100644 --- a/core/java/android/view/RemotableViewMethod.java +++ b/core/java/android/view/RemotableViewMethod.java @@ -36,6 +36,3 @@ public @interface RemotableViewMethod { */ String asyncImpl() default ""; } - - - diff --git a/core/java/android/view/RenderNodeAnimatorSetHelper.java b/core/java/android/view/RenderNodeAnimatorSetHelper.java index ba592d29fa3d..e1ef05941394 100644 --- a/core/java/android/view/RenderNodeAnimatorSetHelper.java +++ b/core/java/android/view/RenderNodeAnimatorSetHelper.java @@ -16,6 +16,7 @@ package android.view; import android.animation.TimeInterpolator; + import com.android.internal.view.animation.FallbackLUTInterpolator; import com.android.internal.view.animation.NativeInterpolatorFactory; import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; diff --git a/core/java/android/view/RoundScrollbarRenderer.java b/core/java/android/view/RoundScrollbarRenderer.java index b77be8c00e69..4c555aed40cc 100644 --- a/core/java/android/view/RoundScrollbarRenderer.java +++ b/core/java/android/view/RoundScrollbarRenderer.java @@ -19,8 +19,8 @@ package android.view; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.graphics.RectF; import android.graphics.Rect; +import android.graphics.RectF; /** * Helper class for drawing round scroll bars on round Wear devices. diff --git a/core/java/android/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java index 7cd161c17cd9..9787494c5018 100644 --- a/core/java/android/view/ScaleGestureDetector.java +++ b/core/java/android/view/ScaleGestureDetector.java @@ -20,7 +20,6 @@ import android.content.Context; import android.content.res.Resources; import android.os.Build; import android.os.Handler; -import android.os.SystemClock; /** * Detects scaling transformation gestures using the supplied {@link MotionEvent}s. diff --git a/core/java/android/view/SearchEvent.java b/core/java/android/view/SearchEvent.java index 643cc3ee28ec..72b5e4ba7398 100644 --- a/core/java/android/view/SearchEvent.java +++ b/core/java/android/view/SearchEvent.java @@ -16,8 +16,6 @@ package android.view; -import android.view.InputDevice; - /** * Class that contains information about an event that triggers a search. */ diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index 22e68a3b909c..ecd5e3b22188 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -26,11 +26,11 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.Log; +import dalvik.system.CloseGuard; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import dalvik.system.CloseGuard; - /** * Handle onto a raw buffer that is being managed by the screen compositor. * diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 64568260c022..b87250e5f131 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -16,7 +16,6 @@ package android.view; -import dalvik.system.CloseGuard; import android.graphics.Bitmap; import android.graphics.Rect; import android.graphics.Region; @@ -24,6 +23,8 @@ import android.os.IBinder; import android.util.Log; import android.view.Surface.OutOfResourcesException; +import dalvik.system.CloseGuard; + /** * SurfaceControl * @hide diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 816bcf09a89d..80f447ec51f8 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -16,11 +16,9 @@ package android.view; -import com.android.internal.view.BaseIWindow; - import android.content.Context; -import android.content.res.Configuration; import android.content.res.CompatibilityInfo.Translator; +import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.PixelFormat; import android.graphics.PorterDuff; @@ -28,12 +26,14 @@ import android.graphics.Rect; import android.graphics.Region; import android.os.Handler; import android.os.Message; +import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.SystemClock; -import android.os.ParcelFileDescriptor; import android.util.AttributeSet; import android.util.Log; +import com.android.internal.view.BaseIWindow; + import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.concurrent.locks.ReentrantLock; diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java index f71459e426dc..0bb84cca174a 100644 --- a/core/java/android/view/ThreadedRenderer.java +++ b/core/java/android/view/ThreadedRenderer.java @@ -16,9 +16,9 @@ package android.view; -import android.app.ActivityManagerNative; import android.annotation.IntDef; import android.annotation.NonNull; +import android.app.ActivityManagerNative; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; diff --git a/core/java/android/view/TouchDelegate.java b/core/java/android/view/TouchDelegate.java index 27b49dbb377c..cf36f4360c3b 100644 --- a/core/java/android/view/TouchDelegate.java +++ b/core/java/android/view/TouchDelegate.java @@ -17,9 +17,6 @@ package android.view; import android.graphics.Rect; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewConfiguration; /** * Helper class to handle situations where you want a view to have a larger touch area than its @@ -33,24 +30,24 @@ import android.view.ViewConfiguration; * </p> */ public class TouchDelegate { - + /** - * View that should receive forwarded touch events + * View that should receive forwarded touch events */ private View mDelegateView; - + /** * Bounds in local coordinates of the containing view that should be mapped to the delegate * view. This rect is used for initial hit testing. */ private Rect mBounds; - + /** * mBounds inflated to include some slop. This rect is to track whether the motion events * should be considered to be be within the delegate view. */ private Rect mSlopBounds; - + /** * True if the delegate had been targeted on a down event (intersected mBounds). */ @@ -82,7 +79,7 @@ public class TouchDelegate { /** * Constructor - * + * * @param bounds Bounds in local coordinates of the containing view that should be mapped to * the delegate view * @param delegateView The view that should receive motion events @@ -99,7 +96,7 @@ public class TouchDelegate { /** * Will forward touch events to the delegate view if the event is within the bounds * specified in the constructor. - * + * * @param event The touch event to forward * @return True if the event was forwarded to the delegate, false otherwise. */ @@ -136,7 +133,7 @@ public class TouchDelegate { } if (sendToDelegate) { final View delegateView = mDelegateView; - + if (hit) { // Offset event coordinates to be inside the target view event.setLocation(delegateView.getWidth() / 2, delegateView.getHeight() / 2); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index bdf93e40de47..49d664ea60d9 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -16,6 +16,14 @@ package android.view; +import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH; +import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; +import static android.os.Build.VERSION_CODES.KITKAT; +import static android.os.Build.VERSION_CODES.M; +import static android.os.Build.VERSION_CODES.N; + +import static java.lang.Math.max; + import android.animation.AnimatorInflater; import android.animation.StateListAnimator; import android.annotation.CallSuper; @@ -79,11 +87,11 @@ import android.util.SparseArray; import android.util.StateSet; import android.util.SuperNotCalledException; import android.util.TypedValue; -import android.view.ContextMenu.ContextMenuInfo; import android.view.AccessibilityIterators.CharacterTextSegmentIterator; import android.view.AccessibilityIterators.ParagraphTextSegmentIterator; import android.view.AccessibilityIterators.TextSegmentIterator; import android.view.AccessibilityIterators.WordTextSegmentIterator; +import android.view.ContextMenu.ContextMenuInfo; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEventSource; import android.view.accessibility.AccessibilityManager; @@ -99,17 +107,15 @@ import android.view.inputmethod.InputMethodManager; import android.widget.Checkable; import android.widget.FrameLayout; import android.widget.ScrollBarDrawable; -import static android.os.Build.VERSION_CODES.*; -import static java.lang.Math.max; import com.android.internal.R; import com.android.internal.util.Predicate; import com.android.internal.view.menu.MenuBuilder; import com.android.internal.widget.ScrollBarUtils; + import com.google.android.collect.Lists; import com.google.android.collect.Maps; -import java.lang.NullPointerException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.ref.WeakReference; diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java index e1ff0d6735ab..047a515bb99e 100644 --- a/core/java/android/view/ViewDebug.java +++ b/core/java/android/view/ViewDebug.java @@ -51,8 +51,8 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicReference; /** diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 2e428a734331..87a85f16043a 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -16,6 +16,8 @@ package android.view; +import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; + import android.animation.LayoutTransition; import android.annotation.IdRes; import android.annotation.NonNull; @@ -62,8 +64,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; - /** * <p> * A <code>ViewGroup</code> is a special view that can contain other views diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java index c604234fa577..6c84b63bb241 100644 --- a/core/java/android/view/ViewPropertyAnimator.java +++ b/core/java/android/view/ViewPropertyAnimator.java @@ -17,8 +17,9 @@ package android.view; import android.animation.Animator; -import android.animation.ValueAnimator; import android.animation.TimeInterpolator; +import android.animation.ValueAnimator; + import java.util.ArrayList; import java.util.HashMap; import java.util.Set; @@ -42,7 +43,7 @@ import java.util.Set; * <p>This class is not constructed by the caller, but rather by the View whose properties * it will animate. Calls to {@link android.view.View#animate()} will return a reference * to the appropriate ViewPropertyAnimator object for that View.</p> - * + * */ public class ViewPropertyAnimator { @@ -332,7 +333,7 @@ public class ViewPropertyAnimator { * Sets the interpolator for the underlying animator that animates the requested properties. * By default, the animator uses the default interpolator for ValueAnimator. Calling this method * will cause the declared object to be used instead. - * + * * @param interpolator The TimeInterpolator to be used for ensuing property animations. A value * of <code>null</code> will result in linear interpolation. * @return This object, allowing calls to methods in this class to be chained. diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index b046e2d5c768..2c1383174eb6 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -16,6 +16,8 @@ package android.view; +import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; + import android.annotation.ColorInt; import android.annotation.DrawableRes; import android.annotation.IdRes; @@ -24,7 +26,6 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.StyleRes; import android.annotation.SystemApi; -import android.app.ActivityManagerNative; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; @@ -44,8 +45,6 @@ import android.transition.Transition; import android.transition.TransitionManager; import android.view.accessibility.AccessibilityEvent; -import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; - import java.util.List; /** diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index dd4e09685362..c1b8f04a6865 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -23,7 +23,6 @@ import android.os.IBinder; import android.os.RemoteException; import com.android.internal.os.IResultReceiver; -import com.android.internal.R; import java.util.List; @@ -38,11 +37,11 @@ import java.util.List; * Additional window manager specific layout parameters are defined for * control over how windows are displayed. It also implements the {@link WindowManager} * interface, allowing you to control the displays attached to the device. - * + * * <p>Applications will not normally use WindowManager directly, instead relying * on the higher-level facilities in {@link android.app.Activity} and * {@link android.app.Dialog}. - * + * * <p>Even for low-level window manager access, it is almost never correct to use * this class. For example, {@link android.app.Activity#getWindowManager} * provides a window manager for adding windows that are associated with that diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index da361c1c04d2..b30104327f31 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -25,12 +25,12 @@ import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Point; import android.graphics.Rect; -import android.graphics.RectF; import android.os.Bundle; import android.os.IBinder; import android.os.Looper; import android.os.RemoteException; import android.view.animation.Animation; + import com.android.internal.policy.IShortcutService; import java.io.PrintWriter; diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java index c125b32f237a..8084195468c5 100644 --- a/core/java/android/view/accessibility/AccessibilityManager.java +++ b/core/java/android/view/accessibility/AccessibilityManager.java @@ -21,7 +21,6 @@ import android.accessibilityservice.AccessibilityServiceInfo; import android.annotation.NonNull; import android.content.Context; import android.content.pm.PackageManager; -import android.content.pm.ParceledListSlice; import android.content.pm.ServiceInfo; import android.os.Binder; import android.os.Handler; diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java index d89c172be8a7..474db128fcc3 100644 --- a/core/java/android/view/animation/Animation.java +++ b/core/java/android/view/animation/Animation.java @@ -26,6 +26,7 @@ import android.os.Handler; import android.os.SystemProperties; import android.util.AttributeSet; import android.util.TypedValue; + import dalvik.system.CloseGuard; /** @@ -80,13 +81,13 @@ public abstract class Animation implements Cloneable { * order. */ public static final int ZORDER_NORMAL = 0; - + /** * Requests that the content being animated be forced on top of all other * content for the duration of the animation. */ public static final int ZORDER_TOP = 1; - + /** * Requests that the content being animated be forced under all other * content for the duration of the animation. @@ -138,7 +139,7 @@ public abstract class Animation implements Cloneable { /** * Indicates whether fillBefore should be taken into account. */ - boolean mFillEnabled = false; + boolean mFillEnabled = false; /** * The time in milliseconds at which the animation must start; @@ -240,7 +241,7 @@ public abstract class Animation implements Cloneable { setDuration((long) a.getInt(com.android.internal.R.styleable.Animation_duration, 0)); setStartOffset((long) a.getInt(com.android.internal.R.styleable.Animation_startOffset, 0)); - + setFillEnabled(a.getBoolean(com.android.internal.R.styleable.Animation_fillEnabled, mFillEnabled)); setFillBefore(a.getBoolean(com.android.internal.R.styleable.Animation_fillBefore, mFillBefore)); setFillAfter(a.getBoolean(com.android.internal.R.styleable.Animation_fillAfter, mFillAfter)); @@ -249,7 +250,7 @@ public abstract class Animation implements Cloneable { setRepeatMode(a.getInt(com.android.internal.R.styleable.Animation_repeatMode, RESTART)); setZAdjustment(a.getInt(com.android.internal.R.styleable.Animation_zAdjustment, ZORDER_NORMAL)); - + setBackgroundColor(a.getInt(com.android.internal.R.styleable.Animation_background, 0)); setDetachWallpaper(a.getBoolean(com.android.internal.R.styleable.Animation_detachWallpaper, false)); @@ -294,13 +295,13 @@ public abstract class Animation implements Cloneable { /** * Cancel the animation. Cancelling an animation invokes the animation * listener, if set, to notify the end of the animation. - * + * * If you cancel an animation manually, you must call {@link #reset()} * before starting the animation again. - * - * @see #reset() - * @see #start() - * @see #startNow() + * + * @see #reset() + * @see #start() + * @see #startNow() */ public void cancel() { if (mStarted && !mEnded) { @@ -356,7 +357,7 @@ public abstract class Animation implements Cloneable { /** * Sets the handler used to invoke listeners. - * + * * @hide */ public void setListenerHandler(Handler handler) { @@ -424,7 +425,7 @@ public abstract class Animation implements Cloneable { /** * How long this animation should last. The duration cannot be negative. - * + * * @param durationMillis Duration in milliseconds * * @throws java.lang.IllegalArgumentException if the duration is < 0 @@ -443,7 +444,7 @@ public abstract class Animation implements Cloneable { * than <var>durationMillis</var>. In addition to adjusting the duration * itself, this ensures that the repeat count also will not make it run * longer than the given time. - * + * * @param durationMillis The maximum duration the animation is allowed * to run. */ @@ -455,7 +456,7 @@ public abstract class Animation implements Cloneable { mRepeatCount = 0; return; } - + long dur = mDuration + mStartOffset; if (dur > durationMillis) { mDuration = durationMillis-mStartOffset; @@ -480,7 +481,7 @@ public abstract class Animation implements Cloneable { } } } - + /** * How much to scale the duration by. * @@ -528,7 +529,7 @@ public abstract class Animation implements Cloneable { /** * Defines what this animation should do when it reaches the end. This * setting is applied only when the repeat count is either greater than - * 0 or {@link #INFINITE}. Defaults to {@link #RESTART}. + * 0 or {@link #INFINITE}. Defaults to {@link #RESTART}. * * @param repeatMode {@link #RESTART} or {@link #REVERSE} * @attr ref android.R.styleable#Animation_repeatMode @@ -606,7 +607,7 @@ public abstract class Animation implements Cloneable { * @param fillAfter true if the animation should apply its transformation after it ends * @attr ref android.R.styleable#Animation_fillAfter * - * @see #setFillEnabled(boolean) + * @see #setFillEnabled(boolean) */ public void setFillAfter(boolean fillAfter) { mFillAfter = fillAfter; @@ -614,7 +615,7 @@ public abstract class Animation implements Cloneable { /** * Set the Z ordering mode to use while running the animation. - * + * * @param zAdjustment The desired mode, one of {@link #ZORDER_NORMAL}, * {@link #ZORDER_TOP}, or {@link #ZORDER_BOTTOM}. * @attr ref android.R.styleable#Animation_zAdjustment @@ -622,7 +623,7 @@ public abstract class Animation implements Cloneable { public void setZAdjustment(int zAdjustment) { mZAdjustment = zAdjustment; } - + /** * Set background behind animation. * @@ -634,11 +635,11 @@ public abstract class Animation implements Cloneable { } /** - * The scale factor is set by the call to <code>getTransformation</code>. Overrides of + * The scale factor is set by the call to <code>getTransformation</code>. Overrides of * {@link #getTransformation(long, Transformation, float)} will get this value * directly. Overrides of {@link #applyTransformation(float, Transformation)} can * call this method to get the value. - * + * * @return float The scale factor that should be applied to pre-scaled values in * an Animation such as the pivot points in {@link ScaleAnimation} and {@link RotateAnimation}. */ @@ -748,7 +749,7 @@ public abstract class Animation implements Cloneable { /** * Returns the Z ordering mode to use while running the animation as * previously set by {@link #setZAdjustment}. - * + * * @return Returns one of {@link #ZORDER_NORMAL}, * {@link #ZORDER_TOP}, or {@link #ZORDER_BOTTOM}. * @attr ref android.R.styleable#Animation_zAdjustment @@ -827,7 +828,7 @@ public abstract class Animation implements Cloneable { public long computeDurationHint() { return (getStartOffset() + getDuration()) * (getRepeatCount() + 1); } - + /** * Gets the transformation to apply at a specified point in time. Implementations of this * method should always replace the specified Transformation or document they are doing @@ -975,7 +976,7 @@ public abstract class Animation implements Cloneable { * their transforms given an interpolation value. Implementations of this * method should always replace the specified Transformation or document * they are doing otherwise. - * + * * @param interpolatedTime The value of the normalized time (0.0 to 1.0) * after it has been run through the interpolation function. * @param t The Transformation object to fill in with the current @@ -1015,7 +1016,7 @@ public abstract class Animation implements Cloneable { * @param bottom * @param invalidate * @param transformation - * + * * @hide */ public void getInvalidateRegion(int left, int top, int right, int bottom, @@ -1072,7 +1073,7 @@ public abstract class Animation implements Cloneable { /** * Return true if this animation changes the view's alpha property. - * + * * @hide */ public boolean hasAlpha() { diff --git a/core/java/android/view/animation/AnimationSet.java b/core/java/android/view/animation/AnimationSet.java index 71c74506b917..09d4dfc93b19 100644 --- a/core/java/android/view/animation/AnimationSet.java +++ b/core/java/android/view/animation/AnimationSet.java @@ -18,17 +18,17 @@ package android.view.animation; import android.content.Context; import android.content.res.TypedArray; +import android.graphics.RectF; import android.os.Build; import android.util.AttributeSet; -import android.graphics.RectF; import java.util.ArrayList; import java.util.List; /** * Represents a group of Animations that should be played together. - * The transformation of each individual animation are composed - * together into a single transform. + * The transformation of each individual animation are composed + * together into a single transform. * If AnimationSet sets any properties that its children also set * (for example, duration or fillBefore), the values of AnimationSet * override the child values. @@ -72,17 +72,17 @@ public class AnimationSet extends Animation { private long[] mStoredOffsets; /** - * Constructor used when an AnimationSet is loaded from a resource. - * + * Constructor used when an AnimationSet is loaded from a resource. + * * @param context Application context to use * @param attrs Attribute set from which to read values */ public AnimationSet(Context context, AttributeSet attrs) { super(context, attrs); - + TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.AnimationSet); - + setFlag(PROPERTY_SHARE_INTERPOLATOR_MASK, a.getBoolean(com.android.internal.R.styleable.AnimationSet_shareInterpolator, true)); init(); @@ -108,11 +108,11 @@ public class AnimationSet extends Animation { a.recycle(); } - - + + /** * Constructor to use when building an AnimationSet from code - * + * * @param shareInterpolator Pass true if all of the animations in this set * should use the interpolator associated with this AnimationSet. * Pass false if each animation should use its own interpolator. @@ -244,10 +244,10 @@ public class AnimationSet extends Animation { mDirty = true; } - + /** * Sets the start time of this animation and all child animations - * + * * @see android.view.animation.Animation#setStartTime(long) */ @Override @@ -289,11 +289,11 @@ public class AnimationSet extends Animation { animations.get(i).restrictDuration(durationMillis); } } - + /** - * The duration of an AnimationSet is defined to be the + * The duration of an AnimationSet is defined to be the * duration of the longest child animation. - * + * * @see android.view.animation.Animation#getDuration() */ @Override @@ -317,7 +317,7 @@ public class AnimationSet extends Animation { /** * The duration hint of an animation set is the maximum of the duration * hints of all of its component animations. - * + * * @see android.view.animation.Animation#computeDurationHint */ public long computeDurationHint() { @@ -362,7 +362,7 @@ public class AnimationSet extends Animation { /** * The transformation of an animation set is the concatenation of all of its * component animations. - * + * * @see android.view.animation.Animation#getTransformation */ @Override @@ -404,7 +404,7 @@ public class AnimationSet extends Animation { return more; } - + /** * @see android.view.animation.Animation#scaleCurrentDuration(float) */ diff --git a/core/java/android/view/animation/AnimationUtils.java b/core/java/android/view/animation/AnimationUtils.java index 351b6dbd6616..f5c36139df0f 100644 --- a/core/java/android/view/animation/AnimationUtils.java +++ b/core/java/android/view/animation/AnimationUtils.java @@ -16,19 +16,19 @@ package android.view.animation; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - import android.annotation.AnimRes; import android.annotation.InterpolatorRes; import android.content.Context; import android.content.res.Resources; +import android.content.res.Resources.NotFoundException; import android.content.res.Resources.Theme; import android.content.res.XmlResourceParser; -import android.content.res.Resources.NotFoundException; +import android.os.SystemClock; import android.util.AttributeSet; import android.util.Xml; -import android.os.SystemClock; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; diff --git a/core/java/android/view/animation/AnticipateInterpolator.java b/core/java/android/view/animation/AnticipateInterpolator.java index fb66c312181c..7a837c37810c 100644 --- a/core/java/android/view/animation/AnticipateInterpolator.java +++ b/core/java/android/view/animation/AnticipateInterpolator.java @@ -18,8 +18,8 @@ package android.view.animation; import android.content.Context; import android.content.res.Resources; -import android.content.res.TypedArray; import android.content.res.Resources.Theme; +import android.content.res.TypedArray; import android.util.AttributeSet; import com.android.internal.R; diff --git a/core/java/android/view/animation/AnticipateOvershootInterpolator.java b/core/java/android/view/animation/AnticipateOvershootInterpolator.java index 1af72da7a3a4..9a75134a0c21 100644 --- a/core/java/android/view/animation/AnticipateOvershootInterpolator.java +++ b/core/java/android/view/animation/AnticipateOvershootInterpolator.java @@ -16,6 +16,10 @@ package android.view.animation; +import static com.android.internal.R.styleable.AnticipateOvershootInterpolator; +import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_extraTension; +import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_tension; + import android.content.Context; import android.content.res.Resources; import android.content.res.Resources.Theme; @@ -26,10 +30,6 @@ import com.android.internal.view.animation.HasNativeInterpolator; import com.android.internal.view.animation.NativeInterpolatorFactory; import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; -import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_extraTension; -import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_tension; -import static com.android.internal.R.styleable.AnticipateOvershootInterpolator; - /** * An interpolator where the change starts backward then flings forward and overshoots * the target value and finally goes back to the final value. diff --git a/core/java/android/view/animation/CycleInterpolator.java b/core/java/android/view/animation/CycleInterpolator.java index 663c1091ca29..72d64a16393a 100644 --- a/core/java/android/view/animation/CycleInterpolator.java +++ b/core/java/android/view/animation/CycleInterpolator.java @@ -18,8 +18,8 @@ package android.view.animation; import android.content.Context; import android.content.res.Resources; -import android.content.res.TypedArray; import android.content.res.Resources.Theme; +import android.content.res.TypedArray; import android.util.AttributeSet; import com.android.internal.R; diff --git a/core/java/android/view/animation/DecelerateInterpolator.java b/core/java/android/view/animation/DecelerateInterpolator.java index f426f60dc581..f89743c149b1 100644 --- a/core/java/android/view/animation/DecelerateInterpolator.java +++ b/core/java/android/view/animation/DecelerateInterpolator.java @@ -18,8 +18,8 @@ package android.view.animation; import android.content.Context; import android.content.res.Resources; -import android.content.res.TypedArray; import android.content.res.Resources.Theme; +import android.content.res.TypedArray; import android.util.AttributeSet; import com.android.internal.R; diff --git a/core/java/android/view/animation/GridLayoutAnimationController.java b/core/java/android/view/animation/GridLayoutAnimationController.java index 9161d8beba7a..0f189ae98030 100644 --- a/core/java/android/view/animation/GridLayoutAnimationController.java +++ b/core/java/android/view/animation/GridLayoutAnimationController.java @@ -16,11 +16,11 @@ package android.view.animation; -import android.view.View; -import android.view.ViewGroup; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; import java.util.Random; @@ -43,7 +43,7 @@ import java.util.Random; * * @see LayoutAnimationController * @see android.widget.GridView - * + * * @attr ref android.R.styleable#GridLayoutAnimation_columnDelay * @attr ref android.R.styleable#GridLayoutAnimation_rowDelay * @attr ref android.R.styleable#GridLayoutAnimation_direction @@ -206,7 +206,7 @@ public class GridLayoutAnimationController extends LayoutAnimationController { * * @see #getRowDelay() * @see #getColumnDelay() - * @see #setColumnDelay(float) + * @see #setColumnDelay(float) */ public void setRowDelay(float rowDelay) { mRowDelay = rowDelay; diff --git a/core/java/android/view/inputmethod/BaseInputConnection.java b/core/java/android/view/inputmethod/BaseInputConnection.java index 38962a36dd70..5f7a0f789fa4 100644 --- a/core/java/android/view/inputmethod/BaseInputConnection.java +++ b/core/java/android/view/inputmethod/BaseInputConnection.java @@ -1,12 +1,12 @@ /* * Copyright (C) 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. 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 @@ -35,7 +35,6 @@ import android.util.LogPrinter; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.View; -import android.view.ViewRootImpl; class ComposingText implements NoCopySpan { } @@ -56,25 +55,25 @@ public class BaseInputConnection implements InputConnection { protected final InputMethodManager mIMM; final View mTargetView; final boolean mDummyMode; - + private Object[] mDefaultComposingSpans; - + Editable mEditable; KeyCharacterMap mKeyCharacterMap; - + BaseInputConnection(InputMethodManager mgr, boolean fullEditor) { mIMM = mgr; mTargetView = null; mDummyMode = !fullEditor; } - + public BaseInputConnection(View targetView, boolean fullEditor) { mIMM = (InputMethodManager)targetView.getContext().getSystemService( Context.INPUT_METHOD_SERVICE); mTargetView = targetView; mDummyMode = !fullEditor; } - + public static final void removeComposingSpans(Spannable text) { text.removeSpan(COMPOSING); Object[] sps = text.getSpans(0, text.length(), Object.class); @@ -104,8 +103,8 @@ public class BaseInputConnection implements InputConnection { } final int fl = text.getSpanFlags(o); - if ((fl&(Spanned.SPAN_COMPOSING|Spanned.SPAN_POINT_MARK_MASK)) - != (Spanned.SPAN_COMPOSING|Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)) { + if ((fl & (Spanned.SPAN_COMPOSING | Spanned.SPAN_POINT_MARK_MASK)) + != (Spanned.SPAN_COMPOSING | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)) { text.setSpan(o, text.getSpanStart(o), text.getSpanEnd(o), (fl & ~Spanned.SPAN_POINT_MARK_MASK) | Spanned.SPAN_COMPOSING @@ -117,15 +116,15 @@ public class BaseInputConnection implements InputConnection { text.setSpan(COMPOSING, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING); } - + public static int getComposingSpanStart(Spannable text) { return text.getSpanStart(COMPOSING); } - + public static int getComposingSpanEnd(Spannable text) { return text.getSpanEnd(COMPOSING); } - + /** * Return the target of edit operations. The default implementation * returns its own fake editable that is just used for composing text; @@ -139,7 +138,7 @@ public class BaseInputConnection implements InputConnection { } return mEditable; } - + /** * Default implementation does nothing. */ @@ -452,10 +451,10 @@ public class BaseInputConnection implements InputConnection { */ public int getCursorCapsMode(int reqModes) { if (mDummyMode) return 0; - + final Editable content = getEditable(); if (content == null) return 0; - + int a = Selection.getSelectionStart(content); int b = Selection.getSelectionEnd(content); @@ -495,7 +494,7 @@ public class BaseInputConnection implements InputConnection { if (a <= 0) { return ""; } - + if (length > a) { length = a; } @@ -702,7 +701,7 @@ public class BaseInputConnection implements InputConnection { if (!mDummyMode) { return; } - + Editable content = getEditable(); if (content != null) { final int N = content.length(); @@ -727,7 +726,7 @@ public class BaseInputConnection implements InputConnection { return; } } - + // Otherwise, revert to the special key event containing // the actual characters. KeyEvent event = new KeyEvent(SystemClock.uptimeMillis(), @@ -768,7 +767,7 @@ public class BaseInputConnection implements InputConnection { if (content == null) { return; } - + beginBatchEdit(); // delete composing text set previously. @@ -776,7 +775,7 @@ public class BaseInputConnection implements InputConnection { int b = getComposingSpanEnd(content); if (DEBUG) Log.v(TAG, "Composing span: " + a + " to " + b); - + if (b < a) { int tmp = a; a = b; @@ -814,11 +813,11 @@ public class BaseInputConnection implements InputConnection { } setComposingSpans(sp); } - + if (DEBUG) Log.v(TAG, "Replacing from " + a + " to " + b + " with \"" + text + "\", composing=" + composing + ", type=" + text.getClass().getCanonicalName()); - + if (DEBUG) { LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG); lp.println("Current text:"); @@ -842,13 +841,13 @@ public class BaseInputConnection implements InputConnection { Selection.setSelection(content, newCursorPosition); content.replace(a, b, text); - + if (DEBUG) { LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG); lp.println("Final text:"); TextUtils.dumpSpans(content, lp, " "); } - + endBatchEdit(); } diff --git a/core/java/android/view/inputmethod/InputConnectionInspector.java b/core/java/android/view/inputmethod/InputConnectionInspector.java index 2b292bbca849..5f25bf58ce57 100644 --- a/core/java/android/view/inputmethod/InputConnectionInspector.java +++ b/core/java/android/view/inputmethod/InputConnectionInspector.java @@ -16,6 +16,8 @@ package android.view.inputmethod; +import static java.lang.annotation.RetentionPolicy.SOURCE; + import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; @@ -28,8 +30,6 @@ import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; -import static java.lang.annotation.RetentionPolicy.SOURCE; - /** * @hide */ diff --git a/core/java/android/view/inputmethod/InputMethodInfo.java b/core/java/android/view/inputmethod/InputMethodInfo.java index 661b52fd4366..5c8e6dc39960 100644 --- a/core/java/android/view/inputmethod/InputMethodInfo.java +++ b/core/java/android/view/inputmethod/InputMethodInfo.java @@ -16,9 +16,6 @@ package android.view.inputmethod; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - import android.content.ComponentName; import android.content.Context; import android.content.pm.ApplicationInfo; @@ -39,6 +36,9 @@ import android.util.Slog; import android.util.Xml; import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + import java.io.IOException; import java.util.ArrayList; import java.util.List; diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index ca370dc749ef..2e99092006f0 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -1,12 +1,12 @@ /* * Copyright (C) 2007-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. 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 @@ -16,15 +16,7 @@ package android.view.inputmethod; -import com.android.internal.inputmethod.IInputContentUriToken; -import com.android.internal.os.SomeArgs; -import com.android.internal.view.IInputConnectionWrapper; -import com.android.internal.view.IInputContext; -import com.android.internal.view.IInputMethodClient; -import com.android.internal.view.IInputMethodManager; -import com.android.internal.view.IInputMethodSession; -import com.android.internal.view.InputBindResult; -import com.android.internal.view.InputMethodClient; +import static android.Manifest.permission.WRITE_SECURE_SETTINGS; import android.annotation.NonNull; import android.annotation.Nullable; @@ -40,8 +32,8 @@ import android.os.Message; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; -import android.os.Trace; import android.os.ServiceManager.ServiceNotFoundException; +import android.os.Trace; import android.text.TextUtils; import android.text.style.SuggestionSpan; import android.util.Log; @@ -56,11 +48,19 @@ import android.view.InputEventSender; import android.view.KeyEvent; import android.view.View; import android.view.ViewRootImpl; -import android.view.textservice.TextServicesManager; + +import com.android.internal.inputmethod.IInputContentUriToken; +import com.android.internal.os.SomeArgs; +import com.android.internal.view.IInputConnectionWrapper; +import com.android.internal.view.IInputContext; +import com.android.internal.view.IInputMethodClient; +import com.android.internal.view.IInputMethodManager; +import com.android.internal.view.IInputMethodSession; +import com.android.internal.view.InputBindResult; +import com.android.internal.view.InputMethodClient; import java.io.FileDescriptor; import java.io.PrintWriter; -import java.security.InvalidParameterException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -70,14 +70,12 @@ import java.util.Objects; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import static android.Manifest.permission.WRITE_SECURE_SETTINGS; - /** * Central system API to the overall input method framework (IMF) architecture, * which arbitrates interaction between applications and the current input method. * You can retrieve an instance of this interface with * {@link Context#getSystemService(String) Context.getSystemService()}. - * + * * <p>Topics covered here: * <ol> * <li><a href="#ArchitectureOverview">Architecture Overview</a> @@ -85,13 +83,13 @@ import static android.Manifest.permission.WRITE_SECURE_SETTINGS; * <li><a href="#InputMethods">Input Methods</a> * <li><a href="#Security">Security</a> * </ol> - * + * * <a name="ArchitectureOverview"></a> * <h3>Architecture Overview</h3> - * + * * <p>There are three primary parties involved in the input method * framework (IMF) architecture:</p> - * + * * <ul> * <li> The <strong>input method manager</strong> as expressed by this class * is the central point of the system that manages interaction between all @@ -106,16 +104,16 @@ import static android.Manifest.permission.WRITE_SECURE_SETTINGS; * method manager for input focus and control over the state of the IME. Only * one such client is ever active (working with the IME) at a time. * </ul> - * - * + * + * * <a name="Applications"></a> * <h3>Applications</h3> - * + * * <p>In most cases, applications that are using the standard * {@link android.widget.TextView} or its subclasses will have little they need * to do to work well with soft input methods. The main things you need to * be aware of are:</p> - * + * * <ul> * <li> Properly set the {@link android.R.attr#inputType} in your editable * text views, so that the input method will have enough context to help the @@ -131,43 +129,43 @@ import static android.Manifest.permission.WRITE_SECURE_SETTINGS; * for your window using the same {@link android.R.attr#windowSoftInputMode} * attribute. * </ul> - * + * * <p>More finer-grained control is available through the APIs here to directly * interact with the IMF and its IME -- either showing or hiding the input * area, letting the user pick an input method, etc.</p> - * + * * <p>For the rare people amongst us writing their own text editors, you * will need to implement {@link android.view.View#onCreateInputConnection} * to return a new instance of your own {@link InputConnection} interface * allowing the IME to interact with your editor.</p> - * - * + * + * * <a name="InputMethods"></a> * <h3>Input Methods</h3> - * + * * <p>An input method (IME) is implemented * as a {@link android.app.Service}, typically deriving from * {@link android.inputmethodservice.InputMethodService}. It must provide * the core {@link InputMethod} interface, though this is normally handled by * {@link android.inputmethodservice.InputMethodService} and implementors will * only need to deal with the higher-level API there.</p> - * + * * See the {@link android.inputmethodservice.InputMethodService} class for * more information on implementing IMEs. - * - * + * + * * <a name="Security"></a> * <h3>Security</h3> - * + * * <p>There are a lot of security issues associated with input methods, * since they essentially have freedom to completely drive the UI and monitor * everything the user enters. The Android input method framework also allows * arbitrary third party IMEs, so care must be taken to restrict their * selection and interactions.</p> - * + * * <p>Here are some key points about the security architecture behind the * IMF:</p> - * + * * <ul> * <li> <p>Only the system is allowed to directly access an IME's * {@link InputMethod} interface, via the @@ -175,11 +173,11 @@ import static android.Manifest.permission.WRITE_SECURE_SETTINGS; * enforced in the system by not binding to an input method service that does * not require this permission, so the system can guarantee no other untrusted * clients are accessing the current input method outside of its control.</p> - * + * * <li> <p>There may be many client processes of the IMF, but only one may * be active at a time. The inactive clients can not interact with key * parts of the IMF through the mechanisms described below.</p> - * + * * <li> <p>Clients of an input method are only given access to its * {@link InputMethodSession} interface. One instance of this interface is * created for each client, and only calls from the session associated with @@ -187,19 +185,19 @@ import static android.Manifest.permission.WRITE_SECURE_SETTINGS; * by {@link android.inputmethodservice.AbstractInputMethodService} for normal * IMEs, but must be explicitly handled by an IME that is customizing the * raw {@link InputMethodSession} implementation.</p> - * + * * <li> <p>Only the active client's {@link InputConnection} will accept * operations. The IMF tells each client process whether it is active, and * the framework enforces that in inactive processes calls on to the current * InputConnection will be ignored. This ensures that the current IME can * only deliver events and text edits to the UI that the user sees as * being in focus.</p> - * + * * <li> <p>An IME can never interact with an {@link InputConnection} while * the screen is off. This is enforced by making all clients inactive while * the screen is off, and prevents bad IMEs from driving the UI when the user * can not be aware of its behavior.</p> - * + * * <li> <p>A client application can ask that the system let the user pick a * new IME, but can not programmatically switch to one itself. This avoids * malicious applications from switching the user to their own IME, which @@ -207,7 +205,7 @@ import static android.Manifest.permission.WRITE_SECURE_SETTINGS; * IME, on the other hand, <em>is</em> allowed to programmatically switch * the system to another IME, since it already has full control of user * input.</p> - * + * * <li> <p>The user must explicitly enable a new IME in settings before * they can switch to it, to confirm with the system that they know about it * and want to make it available for use.</p> @@ -268,11 +266,11 @@ public final class InputMethodManager { final IInputMethodManager mService; final Looper mMainLooper; - + // For scheduling work on the main thread. This also serves as our // global lock. final H mH; - + // Our generic input connection if the current target does not have its own. final IInputContext mIInputContext; @@ -280,20 +278,20 @@ public final class InputMethodManager { * True if this input method client is active, initially false. */ boolean mActive = false; - + /** * Set whenever this client becomes inactive, to know we need to reset * state with the IME the next time we receive focus. */ boolean mHasBeenInactive = true; - + /** * As reported by IME through InputConnection. */ boolean mFullscreenMode; - + // ----------------------------------------------------------- - + /** * This is the root view of the overall window that currently has input * method focus. @@ -328,7 +326,7 @@ public final class InputMethodManager { * The completions that were last provided by the served view. */ CompletionInfo[] mCompletions; - + // Cursor position on the screen. Rect mTmpCursorRect = new Rect(); Rect mCursorRect = new Rect(); @@ -389,7 +387,7 @@ public final class InputMethodManager { final SparseArray<PendingEvent> mPendingEvents = new SparseArray<>(20); // ----------------------------------------------------------- - + static final int MSG_DUMP = 1; static final int MSG_BIND = 2; static final int MSG_UNBIND = 3; @@ -403,7 +401,7 @@ public final class InputMethodManager { H(Looper looper) { super(looper, null, true); } - + @Override public void handleMessage(Message msg) { switch (msg.what) { @@ -654,7 +652,7 @@ public final class InputMethodManager { return sInstance; } } - + /** * Private optimization: retrieve the global InputMethodManager instance, * if it exists. @@ -663,17 +661,17 @@ public final class InputMethodManager { public static InputMethodManager peekInstance() { return sInstance; } - + /** @hide */ public IInputMethodClient getClient() { return mClient; } - + /** @hide */ public IInputContext getInputContext() { return mIInputContext; } - + public List<InputMethodInfo> getInputMethodList() { try { return mService.getInputMethodList(); @@ -784,7 +782,7 @@ public final class InputMethodManager { && mCurrentTextBoxAttribute != null; } } - + /** * Return true if any view is currently active in the input method. */ @@ -794,7 +792,7 @@ public final class InputMethodManager { return mServedView != null && mCurrentTextBoxAttribute != null; } } - + /** * Return true if the currently served view is accepting full text edits. * If false, it has no input connection, so can only handle raw key events. @@ -871,7 +869,7 @@ public final class InputMethodManager { || !mServedView.checkInputConnectionProxy(view))) { return; } - + mCompletions = completions; if (mCurMethod != null) { try { @@ -881,7 +879,7 @@ public final class InputMethodManager { } } } - + public void updateExtractedText(View view, int token, ExtractedText text) { checkFocus(); synchronized (mH) { @@ -889,7 +887,7 @@ public final class InputMethodManager { || !mServedView.checkInputConnectionProxy(view))) { return; } - + if (mCurMethod != null) { try { mCurMethod.updateExtractedText(token, text); @@ -898,26 +896,26 @@ public final class InputMethodManager { } } } - + /** * Flag for {@link #showSoftInput} to indicate that this is an implicit * request to show the input window, not as the result of a direct request * by the user. The window may not be shown in this case. */ public static final int SHOW_IMPLICIT = 0x0001; - + /** * Flag for {@link #showSoftInput} to indicate that the user has forced * the input method open (such as by long-pressing menu) so it should * not be closed until they explicitly do so. */ public static final int SHOW_FORCED = 0x0002; - + /** * Synonym for {@link #showSoftInput(View, int, ResultReceiver)} without * a result receiver: explicitly request that the current input method's * soft input area be shown to the user, if needed. - * + * * @param view The currently focused view, which would like to receive * soft keyboard input. * @param flags Provides additional operating flags. Currently may be @@ -926,7 +924,7 @@ public final class InputMethodManager { public boolean showSoftInput(View view, int flags) { return showSoftInput(view, flags, null); } - + /** * Flag for the {@link ResultReceiver} result code from * {@link #showSoftInput(View, int, ResultReceiver)} and @@ -934,7 +932,7 @@ public final class InputMethodManager { * state of the soft input window was unchanged and remains shown. */ public static final int RESULT_UNCHANGED_SHOWN = 0; - + /** * Flag for the {@link ResultReceiver} result code from * {@link #showSoftInput(View, int, ResultReceiver)} and @@ -942,7 +940,7 @@ public final class InputMethodManager { * state of the soft input window was unchanged and remains hidden. */ public static final int RESULT_UNCHANGED_HIDDEN = 1; - + /** * Flag for the {@link ResultReceiver} result code from * {@link #showSoftInput(View, int, ResultReceiver)} and @@ -950,7 +948,7 @@ public final class InputMethodManager { * state of the soft input window changed from hidden to shown. */ public static final int RESULT_SHOWN = 2; - + /** * Flag for the {@link ResultReceiver} result code from * {@link #showSoftInput(View, int, ResultReceiver)} and @@ -958,7 +956,7 @@ public final class InputMethodManager { * state of the soft input window changed from shown to hidden. */ public static final int RESULT_HIDDEN = 3; - + /** * Explicitly request that the current input method's soft input area be * shown to the user, if needed. Call this if the user interacts with @@ -1000,7 +998,7 @@ public final class InputMethodManager { } } } - + /** @hide */ public void showSoftInputUnchecked(int flags, ResultReceiver resultReceiver) { try { @@ -1009,14 +1007,14 @@ public final class InputMethodManager { throw e.rethrowFromSystemServer(); } } - + /** * Flag for {@link #hideSoftInputFromWindow} to indicate that the soft * input window should only be hidden if it was not explicitly shown * by the user. */ public static final int HIDE_IMPLICIT_ONLY = 0x0001; - + /** * Flag for {@link #hideSoftInputFromWindow} to indicate that the soft * input window should normally be hidden, unless it was originally @@ -1028,7 +1026,7 @@ public final class InputMethodManager { * Synonym for {@link #hideSoftInputFromWindow(IBinder, int, ResultReceiver)} * without a result: request to hide the soft input window from the * context of the window that is currently accepting input. - * + * * @param windowToken The token of the window that is making the request, * as returned by {@link View#getWindowToken() View.getWindowToken()}. * @param flags Provides additional operating flags. Currently may be @@ -1037,7 +1035,7 @@ public final class InputMethodManager { public boolean hideSoftInputFromWindow(IBinder windowToken, int flags) { return hideSoftInputFromWindow(windowToken, flags, null); } - + /** * Request to hide the soft input window from the context of the window * that is currently accepting input. This should be called as a result @@ -1079,11 +1077,11 @@ public final class InputMethodManager { } } } - + /** * This method toggles the input method window display. - * If the input window is already displayed, it gets hidden. + * If the input window is already displayed, it gets hidden. * If not the input window will be displayed. * @param windowToken The token of the window that is making the request, * as returned by {@link View#getWindowToken() View.getWindowToken()}. @@ -1110,7 +1108,7 @@ public final class InputMethodManager { /* * This method toggles the input method window display. - * If the input window is already displayed, it gets hidden. + * If the input window is already displayed, it gets hidden. * If not the input window will be displayed. * @param showFlags Provides additional operating flags. May be * 0 or have the {@link #SHOW_IMPLICIT}, @@ -1134,7 +1132,7 @@ public final class InputMethodManager { * restart it with its new contents. You should call this when the text * within your view changes outside of the normal input method or key * input flow, such as when an application calls TextView.setText(). - * + * * @param view The view whose text has changed. */ public void restartInput(View view) { @@ -1144,7 +1142,7 @@ public final class InputMethodManager { || !mServedView.checkInputConnectionProxy(view))) { return; } - + mServedConnecting = true; } @@ -1196,7 +1194,7 @@ public final class InputMethodManager { }); return false; } - + // Okay we are now ready to call into the served view and have it // do its stuff. // Life is good: let's hook everything up! @@ -1465,7 +1463,7 @@ public final class InputMethodManager { return true; } - + void closeCurrentInput() { try { mService.hideSoftInput(mClient, HIDE_NOT_ALWAYS, null); @@ -1504,7 +1502,7 @@ public final class InputMethodManager { if (first) { controlFlags |= CONTROL_WINDOW_FIRST; } - + if (checkFocusNoStartInput(forceNewFocus)) { // We need to restart input on the current focus view. This // should be done in conjunction with telling the system service @@ -1792,7 +1790,7 @@ public final class InputMethodManager { * Close/hide the input method's soft input area, so the user no longer * sees it or can interact with it. This can only be called * from the currently active input method, as validated by the given token. - * + * * @param token Supplies the identifying token given to an input method * when it was started, which allows it to perform this operation on * itself. @@ -1807,13 +1805,13 @@ public final class InputMethodManager { throw e.rethrowFromSystemServer(); } } - + /** - * Show the input method's soft input area, so the user + * Show the input method's soft input area, so the user * sees the input method window and can interact with it. * This can only be called from the currently active input method, * as validated by the given token. - * + * * @param token Supplies the identifying token given to an input method * when it was started, which allows it to perform this operation on * itself. @@ -2335,7 +2333,7 @@ public final class InputMethodManager { void doDump(FileDescriptor fd, PrintWriter fout, String[] args) { final Printer p = new PrintWriterPrinter(fout); p.println("Input method client state for " + this + ":"); - + p.println(" mService=" + mService); p.println(" mMainLooper=" + mMainLooper); p.println(" mIInputContext=" + mIInputContext); diff --git a/core/java/android/view/textservice/SpellCheckerInfo.java b/core/java/android/view/textservice/SpellCheckerInfo.java index fc17f7aed301..7aa2c23ae5e0 100644 --- a/core/java/android/view/textservice/SpellCheckerInfo.java +++ b/core/java/android/view/textservice/SpellCheckerInfo.java @@ -16,9 +16,6 @@ package android.view.textservice; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; @@ -35,6 +32,9 @@ import android.util.PrintWriterPrinter; import android.util.Slog; import android.util.Xml; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; diff --git a/core/java/android/view/textservice/SpellCheckerSession.java b/core/java/android/view/textservice/SpellCheckerSession.java index e77dc0dd97d8..729eb8d131a7 100644 --- a/core/java/android/view/textservice/SpellCheckerSession.java +++ b/core/java/android/view/textservice/SpellCheckerSession.java @@ -16,11 +16,6 @@ package android.view.textservice; -import com.android.internal.textservice.ISpellCheckerSession; -import com.android.internal.textservice.ISpellCheckerSessionListener; -import com.android.internal.textservice.ITextServicesManager; -import com.android.internal.textservice.ITextServicesSessionListener; - import android.os.Binder; import android.os.Handler; import android.os.HandlerThread; @@ -29,6 +24,11 @@ import android.os.Process; import android.os.RemoteException; import android.util.Log; +import com.android.internal.textservice.ISpellCheckerSession; +import com.android.internal.textservice.ISpellCheckerSessionListener; +import com.android.internal.textservice.ITextServicesManager; +import com.android.internal.textservice.ITextServicesSessionListener; + import java.util.LinkedList; import java.util.Queue; diff --git a/core/java/android/view/textservice/SpellCheckerSubtype.java b/core/java/android/view/textservice/SpellCheckerSubtype.java index 8dff0c67eeee..026610ecb6f9 100644 --- a/core/java/android/view/textservice/SpellCheckerSubtype.java +++ b/core/java/android/view/textservice/SpellCheckerSubtype.java @@ -16,8 +16,6 @@ package android.view.textservice; -import com.android.internal.inputmethod.InputMethodUtils; - import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; @@ -27,6 +25,8 @@ import android.os.Parcelable; import android.text.TextUtils; import android.util.Slog; +import com.android.internal.inputmethod.InputMethodUtils; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; diff --git a/core/java/android/view/textservice/SuggestionsInfo.java b/core/java/android/view/textservice/SuggestionsInfo.java index 78bc1a9678f1..dc2051cccbf6 100644 --- a/core/java/android/view/textservice/SuggestionsInfo.java +++ b/core/java/android/view/textservice/SuggestionsInfo.java @@ -16,11 +16,11 @@ package android.view.textservice; -import com.android.internal.util.ArrayUtils; - import android.os.Parcel; import android.os.Parcelable; +import com.android.internal.util.ArrayUtils; + /** * This class contains a metadata of suggestions from the text service */ diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index 8ee43342795c..5d136dca51ec 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; @@ -36,6 +34,8 @@ import android.view.MotionEvent; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityNodeInfo; +import com.android.internal.R; + /** * AbsSeekBar extends the capabilities of ProgressBar by adding a draggable thumb. diff --git a/core/java/android/widget/AbsSpinner.java b/core/java/android/widget/AbsSpinner.java index 18db54ec5da0..bc3dfffc1411 100644 --- a/core/java/android/widget/AbsSpinner.java +++ b/core/java/android/widget/AbsSpinner.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.content.Context; import android.content.res.TypedArray; import android.database.DataSetObserver; @@ -29,10 +27,12 @@ import android.util.SparseArray; import android.view.View; import android.view.ViewGroup; +import com.android.internal.R; + /** * An abstract base class for spinner widgets. SDK users will probably not * need to use this class. - * + * * @attr ref android.R.styleable#AbsSpinner_entries */ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { @@ -104,12 +104,12 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { mAdapter.unregisterDataSetObserver(mDataSetObserver); resetList(); } - + mAdapter = adapter; - + mOldSelectedPosition = INVALID_POSITION; mOldSelectedRowId = INVALID_ROW_ID; - + if (mAdapter != null) { mOldItemCount = mItemCount; mItemCount = mAdapter.getCount(); @@ -122,14 +122,14 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { setSelectedPositionInt(position); setNextSelectedPositionInt(position); - + if (mItemCount == 0) { // Nothing selected checkSelectionChanged(); } - + } else { - checkFocus(); + checkFocus(); resetList(); // Nothing selected checkSelectionChanged(); @@ -144,23 +144,23 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { void resetList() { mDataChanged = false; mNeedSync = false; - + removeAllViewsInLayout(); mOldSelectedPosition = INVALID_POSITION; mOldSelectedRowId = INVALID_ROW_ID; - + setSelectedPositionInt(INVALID_POSITION); setNextSelectedPositionInt(INVALID_POSITION); invalidate(); } - /** + /** * @see android.view.View#measure(int, int) - * + * * Figure out the dimensions of this Spinner. The width comes from * the widthMeasureSpec as Spinnners can't have their width set to * UNSPECIFIED. The height is based on the height of the selected item - * plus padding. + * plus padding. */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { @@ -180,11 +180,11 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { if (mDataChanged) { handleDataChanged(); } - + int preferredHeight = 0; int preferredWidth = 0; boolean needsMeasuring = true; - + int selectedPosition = getSelectedItemPosition(); if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) { // Try looking in the recycler. (Maybe we were measured once already) @@ -208,14 +208,14 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { mBlockLayoutRequests = false; } measureChild(view, widthMeasureSpec, heightMeasureSpec); - + preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom; preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right; - + needsMeasuring = false; } } - + if (needsMeasuring) { // No views -- just use padding preferredHeight = mSpinnerPadding.top + mSpinnerPadding.bottom; @@ -238,18 +238,18 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { int getChildHeight(View child) { return child.getMeasuredHeight(); } - + int getChildWidth(View child) { return child.getMeasuredWidth(); } - + @Override protected ViewGroup.LayoutParams generateDefaultLayoutParams() { return new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } - + void recycleAllViews() { final int childCount = getChildCount(); final AbsSpinner.RecycleBin recycleBin = mRecycler; @@ -260,7 +260,7 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { View v = getChildAt(i); int index = position + i; recycleBin.put(index, v); - } + } } /** @@ -279,14 +279,14 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { requestLayout(); invalidate(); } - + /** * Makes the item at the supplied position selected. - * + * * @param position Position to select * @param animate Should the transition be animated - * + * */ void setSelectionInt(int position, boolean animate) { if (position != mOldSelectedPosition) { @@ -308,11 +308,11 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { return null; } } - + /** * Override to prevent spamming ourselves with layout requests * as we place views - * + * * @see android.view.View#requestLayout() */ @Override @@ -334,7 +334,7 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { /** * Maps a point to a position in the list. - * + * * @param x X in local coordinate * @param y Y in local coordinate * @return The position of the item which contains the specified point, or @@ -378,7 +378,7 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { SavedState(Parcelable superState) { super(superState); } - + /** * Constructor called from {@link #CREATOR} */ @@ -431,7 +431,7 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { @Override public void onRestoreInstanceState(Parcelable state) { SavedState ss = (SavedState) state; - + super.onRestoreInstanceState(ss.getSuperState()); if (ss.selectedId >= 0) { @@ -450,7 +450,7 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { public void put(int position, View v) { mScrapHeap.put(position, v); } - + View get(int position) { // System.out.print("Looking for " + position); View result = mScrapHeap.get(position); diff --git a/core/java/android/widget/ActionMenuPresenter.java b/core/java/android/widget/ActionMenuPresenter.java index ac8d578adae8..46269c667a8f 100644 --- a/core/java/android/widget/ActionMenuPresenter.java +++ b/core/java/android/widget/ActionMenuPresenter.java @@ -39,6 +39,7 @@ import android.view.View.MeasureSpec; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityNodeInfo; + import com.android.internal.view.ActionBarPolicy; import com.android.internal.view.menu.ActionMenuItemView; import com.android.internal.view.menu.BaseMenuPresenter; diff --git a/core/java/android/widget/ActionMenuView.java b/core/java/android/widget/ActionMenuView.java index 4d0a1c86fd92..c4bbdb005fe0 100644 --- a/core/java/android/widget/ActionMenuView.java +++ b/core/java/android/widget/ActionMenuView.java @@ -31,6 +31,7 @@ import android.view.ViewDebug; import android.view.ViewGroup; import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; + import com.android.internal.view.menu.ActionMenuItemView; import com.android.internal.view.menu.MenuBuilder; import com.android.internal.view.menu.MenuItemImpl; @@ -45,7 +46,7 @@ import com.android.internal.view.menu.MenuView; */ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvoker, MenuView { private static final String TAG = "ActionMenuView"; - + static final int MIN_CELL_SIZE = 56; // dips static final int GENERATED_ITEM_PADDING = 4; // dips @@ -71,7 +72,7 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo public ActionMenuView(Context context) { this(context, null); } - + public ActionMenuView(Context context, AttributeSet attrs) { super(context, attrs); setBaselineAligned(false); @@ -579,7 +580,7 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo params.gravity = Gravity.CENTER_VERTICAL; return params; } - + @Override public LayoutParams generateLayoutParams(AttributeSet attrs) { return new LayoutParams(getContext(), attrs); diff --git a/core/java/android/widget/ActivityChooserView.java b/core/java/android/widget/ActivityChooserView.java index f5c46db94f4f..51587a74987d 100644 --- a/core/java/android/widget/ActivityChooserView.java +++ b/core/java/android/widget/ActivityChooserView.java @@ -16,9 +16,6 @@ package android.widget; -import com.android.internal.R; -import com.android.internal.view.menu.ShowableListMenu; - import android.annotation.StringRes; import android.content.Context; import android.content.Intent; @@ -39,6 +36,9 @@ import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ActivityChooserModel.ActivityChooserModelClient; +import com.android.internal.R; +import com.android.internal.view.menu.ShowableListMenu; + /** * This class is a view for choosing an activity for handling a given {@link Intent}. * <p> diff --git a/core/java/android/widget/AnalogClock.java b/core/java/android/widget/AnalogClock.java index 7f5e21330b19..bde5f7fd5129 100644 --- a/core/java/android/widget/AnalogClock.java +++ b/core/java/android/widget/AnalogClock.java @@ -16,15 +16,14 @@ package android.widget; +import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.BroadcastReceiver; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.drawable.Drawable; -import android.os.Handler; import android.text.format.DateUtils; import android.text.format.Time; import android.util.AttributeSet; @@ -258,7 +257,7 @@ public class AnalogClock extends View { } onTimeChanged(); - + invalidate(); } }; diff --git a/core/java/android/widget/AppSecurityPermissions.java b/core/java/android/widget/AppSecurityPermissions.java index 1a1680a16f41..68e6809a3f68 100644 --- a/core/java/android/widget/AppSecurityPermissions.java +++ b/core/java/android/widget/AppSecurityPermissions.java @@ -16,10 +16,6 @@ */ package android.widget; -import android.annotation.SystemApi; -import android.os.UserHandle; -import com.android.internal.R; - import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; @@ -31,6 +27,7 @@ import android.content.pm.PermissionGroupInfo; import android.content.pm.PermissionInfo; import android.graphics.drawable.Drawable; import android.os.Parcel; +import android.os.UserHandle; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.util.AttributeSet; @@ -39,6 +36,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import com.android.internal.R; + import java.text.Collator; import java.util.ArrayList; import java.util.Collections; @@ -57,7 +56,7 @@ import java.util.Set; * extended information consisting of all groups and permissions. * To use this view define a LinearLayout or any ViewGroup and add this * view by instantiating AppSecurityPermissions and invoking getPermissionsView. - * + * * {@hide} */ public class AppSecurityPermissions { @@ -324,7 +323,7 @@ public class AppSecurityPermissions { return getPermissionItemViewOld(context, inflater, grpName, description, dangerous, icon); } - + private void getAllUsedPermissions(int sharedUid, Set<MyPermissionInfo> permSet) { String sharedPkgList[] = mPm.getPackagesForUid(sharedUid); if(sharedPkgList == null || (sharedPkgList.length == 0)) { @@ -334,7 +333,7 @@ public class AppSecurityPermissions { getPermissionsForPackage(sharedPkg, permSet); } } - + private void getPermissionsForPackage(String packageName, Set<MyPermissionInfo> permSet) { try { PackageInfo pkgInfo = mPm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS); @@ -417,7 +416,7 @@ public class AppSecurityPermissions { } } } - + public int getPermissionCount() { return getPermissionCount(WHICH_ALL); } @@ -570,7 +569,7 @@ public class AppSecurityPermissions { } return false; } - + private static class PermissionGroupInfoComparator implements Comparator<MyPermissionGroupInfo> { private final Collator sCollator = Collator.getInstance(); @Override @@ -578,7 +577,7 @@ public class AppSecurityPermissions { return sCollator.compare(a.mLabel, b.mLabel); } } - + private static class PermissionInfoComparator implements Comparator<MyPermissionInfo> { private final Collator sCollator = Collator.getInstance(); PermissionInfoComparator() { diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index 6a4e36a9a578..49741d4d111e 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -39,7 +39,9 @@ import android.view.WindowManager; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; + import com.android.internal.R; + import java.lang.ref.WeakReference; /** @@ -362,22 +364,22 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe * <p>Returns the current width for the auto-complete drop down list. This can * be a fixed width, or {@link ViewGroup.LayoutParams#MATCH_PARENT} to fill the screen, or * {@link ViewGroup.LayoutParams#WRAP_CONTENT} to fit the width of its anchor view.</p> - * + * * @return the width for the drop down list - * + * * @attr ref android.R.styleable#AutoCompleteTextView_dropDownWidth */ public int getDropDownWidth() { return mPopup.getWidth(); } - + /** * <p>Sets the current width for the auto-complete drop down list. This can * be a fixed width, or {@link ViewGroup.LayoutParams#MATCH_PARENT} to fill the screen, or * {@link ViewGroup.LayoutParams#WRAP_CONTENT} to fit the width of its anchor view.</p> - * + * * @param width the width to use - * + * * @attr ref android.R.styleable#AutoCompleteTextView_dropDownWidth */ public void setDropDownWidth(int width) { @@ -411,68 +413,68 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe public void setDropDownHeight(int height) { mPopup.setHeight(height); } - + /** * <p>Returns the id for the view that the auto-complete drop down list is anchored to.</p> - * + * * @return the view's id, or {@link View#NO_ID} if none specified - * + * * @attr ref android.R.styleable#AutoCompleteTextView_dropDownAnchor */ public int getDropDownAnchor() { return mDropDownAnchorId; } - + /** * <p>Sets the view to which the auto-complete drop down list should anchor. The view * corresponding to this id will not be loaded until the next time it is needed to avoid * loading a view which is not yet instantiated.</p> - * + * * @param id the id to anchor the drop down list view to - * - * @attr ref android.R.styleable#AutoCompleteTextView_dropDownAnchor + * + * @attr ref android.R.styleable#AutoCompleteTextView_dropDownAnchor */ public void setDropDownAnchor(int id) { mDropDownAnchorId = id; mPopup.setAnchorView(null); } - + /** * <p>Gets the background of the auto-complete drop-down list.</p> - * + * * @return the background drawable - * + * * @attr ref android.R.styleable#PopupWindow_popupBackground */ public Drawable getDropDownBackground() { return mPopup.getBackground(); } - + /** * <p>Sets the background of the auto-complete drop-down list.</p> - * + * * @param d the drawable to set as the background - * + * * @attr ref android.R.styleable#PopupWindow_popupBackground */ public void setDropDownBackgroundDrawable(Drawable d) { mPopup.setBackgroundDrawable(d); } - + /** * <p>Sets the background of the auto-complete drop-down list.</p> - * + * * @param id the id of the drawable to set as the background - * + * * @attr ref android.R.styleable#PopupWindow_popupBackground */ public void setDropDownBackgroundResource(@DrawableRes int id) { mPopup.setBackgroundDrawable(getContext().getDrawable(id)); } - + /** * <p>Sets the vertical offset used for the auto-complete drop-down list.</p> - * + * * @param offset the vertical offset * * @attr ref android.R.styleable#ListPopupWindow_dropDownVerticalOffset @@ -480,10 +482,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe public void setDropDownVerticalOffset(int offset) { mPopup.setVerticalOffset(offset); } - + /** * <p>Gets the vertical offset used for the auto-complete drop-down list.</p> - * + * * @return the vertical offset * * @attr ref android.R.styleable#ListPopupWindow_dropDownVerticalOffset @@ -491,10 +493,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe public int getDropDownVerticalOffset() { return mPopup.getVerticalOffset(); } - + /** * <p>Sets the horizontal offset used for the auto-complete drop-down list.</p> - * + * * @param offset the horizontal offset * * @attr ref android.R.styleable#ListPopupWindow_dropDownHorizontalOffset @@ -502,10 +504,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe public void setDropDownHorizontalOffset(int offset) { mPopup.setHorizontalOffset(offset); } - + /** * <p>Gets the horizontal offset used for the auto-complete drop-down list.</p> - * + * * @return the horizontal offset * * @attr ref android.R.styleable#ListPopupWindow_dropDownHorizontalOffset @@ -567,10 +569,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe public void setDropDownAlwaysVisible(boolean dropDownAlwaysVisible) { mPopup.setDropDownAlwaysVisible(dropDownAlwaysVisible); } - + /** * Checks whether the drop-down is dismissed when a suggestion is clicked. - * + * * @hide Pending API council approval */ public boolean isDropDownDismissedOnCompletion() { @@ -578,17 +580,17 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe } /** - * Sets whether the drop-down is dismissed when a suggestion is clicked. This is + * Sets whether the drop-down is dismissed when a suggestion is clicked. This is * true by default. - * + * * @param dropDownDismissedOnCompletion Whether to dismiss the drop-down. - * + * * @hide Pending API council approval */ public void setDropDownDismissedOnCompletion(boolean dropDownDismissedOnCompletion) { mDropDownDismissedOnCompletion = dropDownDismissedOnCompletion; } - + /** * <p>Returns the number of characters the user must type before the drop * down list is shown.</p> @@ -720,13 +722,13 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe /** * <p>Changes the list of data used for auto completion. The provided list * must be a filterable list adapter.</p> - * + * * <p>The caller is still responsible for managing any resources used by the adapter. * Notably, when the AutoCompleteTextView is closed or released, the adapter is not notified. * A common case is the use of {@link android.widget.CursorAdapter}, which * contains a {@link android.database.Cursor} that must be closed. This can be done - * automatically (see - * {@link android.app.Activity#startManagingCursor(android.database.Cursor) + * automatically (see + * {@link android.app.Activity#startManagingCursor(android.database.Cursor) * startManagingCursor()}), * or by manually closing the cursor when the AutoCompleteTextView is dismissed.</p> * @@ -811,7 +813,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe if (mPopup.onKeyDown(keyCode, event)) { return true; } - + if (!isPopupShowing()) { switch(keyCode) { case KeyEvent.KEYCODE_DPAD_DOWN: @@ -924,18 +926,18 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe protected CharSequence convertSelectionToString(Object selectedItem) { return mFilter.convertResultToString(selectedItem); } - + /** - * <p>Clear the list selection. This may only be temporary, as user input will often bring + * <p>Clear the list selection. This may only be temporary, as user input will often bring * it back. */ public void clearListSelection() { mPopup.clearListSelection(); } - + /** * Set the position of the dropdown view selection. - * + * * @param position The position to move the selector to. */ public void setListSelection(int position) { @@ -943,13 +945,13 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe } /** - * Get the position of the dropdown view selection, if there is one. Returns + * Get the position of the dropdown view selection, if there is one. Returns * {@link ListView#INVALID_POSITION ListView.INVALID_POSITION} if there is no dropdown or if * there is no selection. - * - * @return the position of the current selection, if there is one, or + * + * @return the position of the current selection, if there is one, or * {@link ListView#INVALID_POSITION ListView.INVALID_POSITION} if not. - * + * * @see ListView#getSelectedItemPosition() */ public int getListSelection() { @@ -1020,7 +1022,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe dismissDropDown(); } } - + /** * Identifies whether the view is currently performing a text completion, so subclasses * can decide whether to respond to text changed events. @@ -1172,7 +1174,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe public void showDropDownAfterLayout() { mPopup.postShow(); } - + /** * Ensures that the drop down is not obscuring the IME. * @param visible whether the ime should be in front. If false, the ime is pushed to @@ -1220,7 +1222,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe * Forces outside touches to be ignored. Normally if {@link #isDropDownAlwaysVisible()} is * false, we allow outside touch to dismiss the dropdown. If this is set to true, then we * ignore outside touch even when the drop down is not set to always visible. - * + * * @hide used only by SearchDialog */ public void setForceIgnoreOutsideTouch(boolean forceIgnoreOutsideTouch) { @@ -1245,7 +1247,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe realCount++; } } - + if (realCount != count) { CompletionInfo[] tmp = new CompletionInfo[realCount]; System.arraycopy(completions, 0, tmp, 0, realCount); @@ -1340,7 +1342,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe */ CharSequence fixText(CharSequence invalidText); } - + /** * Listener to respond to the AutoCompleteTextView's completion list being dismissed. * @see AutoCompleteTextView#setOnDismissListener(OnDismissListener) diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java index 6ef15764bf00..db50e343b775 100644 --- a/core/java/android/widget/CalendarView.java +++ b/core/java/android/widget/CalendarView.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.AttrRes; import android.annotation.ColorInt; import android.annotation.DrawableRes; @@ -36,6 +34,8 @@ import android.icu.util.TimeZone; import android.util.AttributeSet; import android.util.Log; +import com.android.internal.R; + import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; diff --git a/core/java/android/widget/CalendarViewLegacyDelegate.java b/core/java/android/widget/CalendarViewLegacyDelegate.java index bcda83fbd95c..557d41179921 100644 --- a/core/java/android/widget/CalendarViewLegacyDelegate.java +++ b/core/java/android/widget/CalendarViewLegacyDelegate.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.app.Service; import android.content.Context; import android.content.res.Configuration; @@ -38,10 +36,12 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import java.util.Locale; +import com.android.internal.R; import libcore.icu.LocaleData; +import java.util.Locale; + /** * A delegate implementing the legacy CalendarView */ diff --git a/core/java/android/widget/CheckBox.java b/core/java/android/widget/CheckBox.java index 15bbdd217751..046f75fd37ac 100644 --- a/core/java/android/widget/CheckBox.java +++ b/core/java/android/widget/CheckBox.java @@ -19,7 +19,6 @@ package android.widget; import android.content.Context; import android.util.AttributeSet; - /** * <p> * A checkbox is a specific type of two-states button that can be either @@ -44,12 +43,12 @@ import android.util.AttributeSet; * * <p>See the <a href="{@docRoot}guide/topics/ui/controls/checkbox.html">Checkboxes</a> * guide.</p> - * - * <p><strong>XML attributes</strong></p> + * + * <p><strong>XML attributes</strong></p> * <p> - * See {@link android.R.styleable#CompoundButton CompoundButton Attributes}, - * {@link android.R.styleable#Button Button Attributes}, - * {@link android.R.styleable#TextView TextView Attributes}, + * See {@link android.R.styleable#CompoundButton CompoundButton Attributes}, + * {@link android.R.styleable#Button Button Attributes}, + * {@link android.R.styleable#TextView TextView Attributes}, * {@link android.R.styleable#View View Attributes} * </p> */ @@ -57,7 +56,7 @@ public class CheckBox extends CompoundButton { public CheckBox(Context context) { this(context, null); } - + public CheckBox(Context context, AttributeSet attrs) { this(context, attrs, com.android.internal.R.attr.checkboxStyle); } diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java index 21595d15e624..92bfd56d8988 100644 --- a/core/java/android/widget/CheckedTextView.java +++ b/core/java/android/widget/CheckedTextView.java @@ -16,11 +16,8 @@ package android.widget; -import android.annotation.NonNull; -import android.view.ViewHierarchyEncoder; -import com.android.internal.R; - import android.annotation.DrawableRes; +import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; @@ -34,9 +31,12 @@ import android.util.AttributeSet; import android.view.Gravity; import android.view.RemotableViewMethod; import android.view.ViewDebug; +import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; +import com.android.internal.R; + /** * An extension to {@link TextView} that supports the {@link Checkable} * interface and displays. @@ -394,7 +394,7 @@ public class CheckedTextView extends TextView implements Checkable { y = (getHeight() - height) / 2; break; } - + final boolean checkMarkAtStart = isCheckMarkAtStart(); final int width = getWidth(); final int top = y; @@ -417,7 +417,7 @@ public class CheckedTextView extends TextView implements Checkable { } } } - + @Override protected int[] onCreateDrawableState(int extraSpace) { final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); diff --git a/core/java/android/widget/Chronometer.java b/core/java/android/widget/Chronometer.java index adcb012674a8..b9224f36a922 100644 --- a/core/java/android/widget/Chronometer.java +++ b/core/java/android/widget/Chronometer.java @@ -24,7 +24,6 @@ import android.text.format.DateUtils; import android.util.AttributeSet; import android.util.Log; import android.view.View; -import android.view.accessibility.AccessibilityEvent; import android.widget.RemoteViews.RemoteView; import com.android.internal.R; @@ -80,7 +79,7 @@ public class Chronometer extends TextView { private OnChronometerTickListener mOnChronometerTickListener; private StringBuilder mRecycle = new StringBuilder(8); private boolean mCountDown; - + /** * Initialize this Chronometer object. * Sets the base to the current time. @@ -191,7 +190,7 @@ public class Chronometer extends TextView { /** * Sets the listener to be called when the chronometer changes. - * + * * @param listener The listener. */ public void setOnChronometerTickListener(OnChronometerTickListener listener) { @@ -209,10 +208,10 @@ public class Chronometer extends TextView { /** * Start counting up. This does not affect the base as set from {@link #setBase}, just * the view display. - * - * Chronometer works by regularly scheduling messages to the handler, even when the - * Widget is not visible. To make sure resource leaks do not occur, the user should - * make sure that each start() call has a reciprocal call to {@link #stop}. + * + * Chronometer works by regularly scheduling messages to the handler, even when the + * Widget is not visible. To make sure resource leaks do not occur, the user should + * make sure that each start() call has a reciprocal call to {@link #stop}. */ public void start() { mStarted = true; @@ -222,9 +221,9 @@ public class Chronometer extends TextView { /** * Stop counting up. This does not affect the base as set from {@link #setBase}, just * the view display. - * + * * This stops the messages to the handler, effectively releasing resources that would - * be held as the chronometer is running, via {@link #start}. + * be held as the chronometer is running, via {@link #start}. */ public void stop() { mStarted = false; diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index 03578342bbed..dd63fef5f26f 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -19,14 +19,11 @@ package android.widget; import android.annotation.DrawableRes; import android.annotation.NonNull; import android.annotation.Nullable; -import android.graphics.PorterDuff; -import android.view.ViewHierarchyEncoder; -import com.android.internal.R; - import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; @@ -34,9 +31,12 @@ import android.util.AttributeSet; import android.view.Gravity; import android.view.SoundEffectConstants; import android.view.ViewDebug; +import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; +import com.android.internal.R; + /** * <p> * A button with two states, checked and unchecked. When the button is pressed @@ -159,7 +159,7 @@ public abstract class CompoundButton extends Button implements Checkable { mOnCheckedChangeWidgetListener.onCheckedChanged(this, mChecked); } - mBroadcasting = false; + mBroadcasting = false; } } @@ -492,7 +492,7 @@ public abstract class CompoundButton extends Button implements Checkable { SavedState(Parcelable superState) { super(superState); } - + /** * Constructor called from {@link #CREATOR} */ diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java index 80f25d40198e..517e20cd1947 100644 --- a/core/java/android/widget/DatePicker.java +++ b/core/java/android/widget/DatePicker.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.TestApi; @@ -35,6 +33,8 @@ import android.util.SparseArray; import android.view.View; import android.view.accessibility.AccessibilityEvent; +import com.android.internal.R; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Locale; diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java index 1bf0c876aa81..f712685ec3e0 100755 --- a/core/java/android/widget/DatePickerCalendarDelegate.java +++ b/core/java/android/widget/DatePickerCalendarDelegate.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; @@ -40,6 +38,8 @@ import android.view.accessibility.AccessibilityEvent; import android.widget.DayPickerView.OnDaySelectedListener; import android.widget.YearPickerView.OnYearSelectedListener; +import com.android.internal.R; + import java.util.Locale; /** diff --git a/core/java/android/widget/DatePickerSpinnerDelegate.java b/core/java/android/widget/DatePickerSpinnerDelegate.java index 9ecf8a54518e..702b2a5f822a 100644 --- a/core/java/android/widget/DatePickerSpinnerDelegate.java +++ b/core/java/android/widget/DatePickerSpinnerDelegate.java @@ -33,14 +33,14 @@ import android.view.inputmethod.InputMethodManager; import android.widget.DatePicker.AbstractDatePickerDelegate; import android.widget.NumberPicker.OnValueChangeListener; +import libcore.icu.ICU; + import java.text.DateFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Locale; -import libcore.icu.ICU; - /** * A delegate implementing the basic DatePicker */ diff --git a/core/java/android/widget/DayPickerPagerAdapter.java b/core/java/android/widget/DayPickerPagerAdapter.java index f748d3aad038..8d5bf8f7bce4 100644 --- a/core/java/android/widget/DayPickerPagerAdapter.java +++ b/core/java/android/widget/DayPickerPagerAdapter.java @@ -16,9 +16,6 @@ package android.widget; -import android.graphics.Rect; -import com.android.internal.widget.PagerAdapter; - import android.annotation.IdRes; import android.annotation.LayoutRes; import android.annotation.NonNull; @@ -26,6 +23,7 @@ import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; +import android.graphics.Rect; import android.icu.util.Calendar; import android.util.SparseArray; import android.view.LayoutInflater; @@ -33,6 +31,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.SimpleMonthView.OnDayClickListener; +import com.android.internal.widget.PagerAdapter; + /** * An adapter for a list of {@link android.widget.SimpleMonthView} items. */ diff --git a/core/java/android/widget/DayPickerView.java b/core/java/android/widget/DayPickerView.java index 0c02a2ba61fa..919c1e2c4a4c 100644 --- a/core/java/android/widget/DayPickerView.java +++ b/core/java/android/widget/DayPickerView.java @@ -18,15 +18,11 @@ package android.widget; import static android.os.Build.VERSION_CODES.N_MR1; -import android.graphics.Rect; -import com.android.internal.R; -import com.android.internal.widget.ViewPager; -import com.android.internal.widget.ViewPager.OnPageChangeListener; - import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; +import android.graphics.Rect; import android.icu.util.Calendar; import android.util.AttributeSet; import android.util.MathUtils; @@ -35,10 +31,14 @@ import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; -import java.util.Locale; +import com.android.internal.R; +import com.android.internal.widget.ViewPager; +import com.android.internal.widget.ViewPager.OnPageChangeListener; import libcore.icu.LocaleData; +import java.util.Locale; + class DayPickerView extends ViewGroup { private static final int DEFAULT_LAYOUT = R.layout.day_picker_content_material; private static final int DEFAULT_START_YEAR = 1900; diff --git a/core/java/android/widget/DayPickerViewPager.java b/core/java/android/widget/DayPickerViewPager.java index 5f0ae29bb96d..94022ae11b6d 100644 --- a/core/java/android/widget/DayPickerViewPager.java +++ b/core/java/android/widget/DayPickerViewPager.java @@ -16,17 +16,12 @@ package android.widget; -import android.annotation.Nullable; import android.content.Context; -import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.View; -import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; import com.android.internal.util.Predicate; -import com.android.internal.widget.PagerAdapter; import com.android.internal.widget.ViewPager; import java.util.ArrayList; diff --git a/core/java/android/widget/DialerFilter.java b/core/java/android/widget/DialerFilter.java index e37e3ba74c1c..8f9c96c8f0e9 100644 --- a/core/java/android/widget/DialerFilter.java +++ b/core/java/android/widget/DialerFilter.java @@ -17,7 +17,7 @@ package android.widget; import android.content.Context; -import android.view.KeyEvent; +import android.graphics.Rect; import android.text.Editable; import android.text.InputFilter; import android.text.Selection; @@ -28,8 +28,8 @@ import android.text.method.DialerKeyListener; import android.text.method.KeyListener; import android.text.method.TextKeyListener; import android.util.AttributeSet; +import android.view.KeyEvent; import android.view.View; -import android.graphics.Rect; /** * This widget is a layout that contains several specifically-named child views that @@ -169,7 +169,7 @@ public class DialerFilter extends RelativeLayout // Only check to see if the digit is valid if the key is a printing key // in the TextKeyListener. This prevents us from hiding the digits // line when keys like UP and DOWN are hit. - // XXX note that KEYCODE_TAB is special-cased here for + // XXX note that KEYCODE_TAB is special-cased here for // devices that share tab and 0 on a single key. boolean isPrint = event.isPrintingKey(); if (isPrint || keyCode == KeyEvent.KEYCODE_SPACE diff --git a/core/java/android/widget/DigitalClock.java b/core/java/android/widget/DigitalClock.java index 1df164308076..c503ef215ea1 100644 --- a/core/java/android/widget/DigitalClock.java +++ b/core/java/android/widget/DigitalClock.java @@ -23,6 +23,7 @@ import android.os.SystemClock; import android.provider.Settings; import android.text.format.DateFormat; import android.util.AttributeSet; + import java.util.Calendar; /** diff --git a/core/java/android/widget/DropDownListView.java b/core/java/android/widget/DropDownListView.java index 69e42180aa6a..e9c472821d08 100644 --- a/core/java/android/widget/DropDownListView.java +++ b/core/java/android/widget/DropDownListView.java @@ -17,13 +17,13 @@ package android.widget; -import com.android.internal.widget.AutoScrollHelper.AbsListViewAutoScroller; - import android.annotation.NonNull; import android.content.Context; import android.view.MotionEvent; import android.view.View; +import com.android.internal.widget.AutoScrollHelper.AbsListViewAutoScroller; + /** * Wrapper class for a ListView. This wrapper can hijack the focus to * make sure the list uses the appropriate drawables and states when diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java index 9019f3123135..98d8a13d68b5 100644 --- a/core/java/android/widget/EdgeEffect.java +++ b/core/java/android/widget/EdgeEffect.java @@ -17,14 +17,13 @@ package android.widget; import android.annotation.ColorInt; +import android.content.Context; import android.content.res.TypedArray; +import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; - -import android.content.Context; -import android.graphics.Canvas; import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; @@ -103,7 +102,7 @@ public class EdgeEffect { private int mState = STATE_IDLE; private float mPullDistance; - + private final Rect mBounds = new Rect(); private final Paint mPaint = new Paint(); private float mRadius; diff --git a/core/java/android/widget/EditText.java b/core/java/android/widget/EditText.java index 24d861843a13..a8d3984adc7e 100644 --- a/core/java/android/widget/EditText.java +++ b/core/java/android/widget/EditText.java @@ -17,7 +17,6 @@ package android.widget; import android.content.Context; -import android.os.Bundle; import android.text.Editable; import android.text.Selection; import android.text.Spannable; diff --git a/core/java/android/widget/ExpandableListView.java b/core/java/android/widget/ExpandableListView.java index fac36c578da8..8d9848d41c59 100644 --- a/core/java/android/widget/ExpandableListView.java +++ b/core/java/android/widget/ExpandableListView.java @@ -16,7 +16,7 @@ package android.widget; -import com.android.internal.R; +import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; import android.content.Context; import android.content.res.TypedArray; @@ -27,14 +27,14 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; import android.view.ContextMenu; +import android.view.ContextMenu.ContextMenuInfo; import android.view.SoundEffectConstants; import android.view.View; -import android.view.ContextMenu.ContextMenuInfo; import android.widget.ExpandableListConnector.PositionMetadata; -import java.util.ArrayList; +import com.android.internal.R; -import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; +import java.util.ArrayList; /** * A view that shows items in a vertically scrolling two-level list. This @@ -68,7 +68,7 @@ import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; * wrap_content since it also can be any length. However, you can use * wrap_content if the ExpandableListView parent has a specific size, such as * 100 pixels. - * + * * @attr ref android.R.styleable#ExpandableListView_groupIndicator * @attr ref android.R.styleable#ExpandableListView_indicatorLeft * @attr ref android.R.styleable#ExpandableListView_indicatorRight @@ -87,7 +87,7 @@ public class ExpandableListView extends ListView { * The packed position represents a group. */ public static final int PACKED_POSITION_TYPE_GROUP = 0; - + /** * The packed position represents a child. */ @@ -97,14 +97,14 @@ public class ExpandableListView extends ListView { * The packed position represents a neither/null/no preference. */ public static final int PACKED_POSITION_TYPE_NULL = 2; - + /** * The value for a packed position that represents neither/null/no * preference. This value is not otherwise possible since a group type * (first bit 0) should not have a child position filled. */ public static final long PACKED_POSITION_VALUE_NULL = 0x00000000FFFFFFFFL; - + /** The mask (in packed position representation) for the child */ private static final long PACKED_POSITION_MASK_CHILD = 0x00000000FFFFFFFFL; @@ -125,13 +125,13 @@ public class ExpandableListView extends ListView { /** The mask (in integer group position representation) for the group */ private static final long PACKED_POSITION_INT_MASK_GROUP = 0x7FFFFFFF; - + /** Serves as the glue/translator between a ListView and an ExpandableListView */ private ExpandableListConnector mConnector; - - /** Gives us Views through group+child positions */ + + /** Gives us Views through group+child positions */ private ExpandableListAdapter mAdapter; - + /** Left bound for drawing the indicator. */ private int mIndicatorLeft; @@ -210,7 +210,7 @@ public class ExpandableListView extends ListView { /** State indicating the child is the last within its group. */ private static final int[] CHILD_LAST_STATE_SET = {R.attr.state_last}; - + /** Drawable to be used as a divider when it is adjacent to any children */ private Drawable mChildDivider; @@ -367,16 +367,16 @@ public class ExpandableListView extends ListView { } final int headerViewsCount = getHeaderViewsCount(); - + final int lastChildFlPos = mItemCount - getFooterViewsCount() - headerViewsCount - 1; - final int myB = mBottom; - + final int myB = mBottom; + PositionMetadata pos; View item; - Drawable indicator; + Drawable indicator; int t, b; - + // Start at a value that is neither child nor group int lastItemType = ~(ExpandableListPosition.CHILD | ExpandableListPosition.GROUP); @@ -385,7 +385,7 @@ public class ExpandableListView extends ListView { // The "child" mentioned in the following two lines is this // View's child, not referring to an expandable list's // notion of a child (as opposed to a group) - final int childCount = getChildCount(); + final int childCount = getChildCount(); for (int i = 0, childFlPos = mFirstPosition - headerViewsCount; i < childCount; i++, childFlPos++) { @@ -396,11 +396,11 @@ public class ExpandableListView extends ListView { // This child is footer, so are all subsequent children break; } - + item = getChildAt(i); t = item.getTop(); b = item.getBottom(); - + // This item isn't on the screen if ((b < 0) || (t > myB)) continue; @@ -435,7 +435,7 @@ public class ExpandableListView extends ListView { indicatorRect.right += mPaddingLeft; } - lastItemType = pos.position.type; + lastItemType = pos.position.type; } if (indicatorRect.left != indicatorRect.right) { @@ -448,7 +448,7 @@ public class ExpandableListView extends ListView { indicatorRect.top = t; indicatorRect.bottom = b;// + mDividerHeight; } - + // Get the indicator (with its state set to the item's state) indicator = getIndicator(pos); if (indicator != null) { @@ -468,24 +468,24 @@ public class ExpandableListView extends ListView { /** * Gets the indicator for the item at the given position. If the indicator * is stateful, the state will be given to the indicator. - * + * * @param pos The flat list position of the item whose indicator * should be returned. * @return The indicator in the proper state. */ private Drawable getIndicator(PositionMetadata pos) { Drawable indicator; - + if (pos.position.type == ExpandableListPosition.GROUP) { indicator = mGroupIndicator; - + if (indicator != null && indicator.isStateful()) { // Empty check based on availability of data. If the groupMetadata isn't null, // we do a check on it. Otherwise, the group is collapsed so we consider it // empty for performance reasons. boolean isEmpty = (pos.groupMetadata == null) || (pos.groupMetadata.lastChildFlPos == pos.groupMetadata.flPos); - + final int stateSetIndex = (pos.isExpanded() ? 1 : 0) | // Expanded? (isEmpty ? 2 : 0); // Empty? @@ -493,7 +493,7 @@ public class ExpandableListView extends ListView { } } else { indicator = mChildIndicator; - + if (indicator != null && indicator.isStateful()) { // No need for a state sets array for the child since it only has two states final int stateSet[] = pos.position.flatListPos == pos.groupMetadata.lastChildFlPos @@ -502,15 +502,15 @@ public class ExpandableListView extends ListView { indicator.setState(stateSet); } } - + return indicator; } - + /** * Sets the drawable that will be drawn adjacent to every child in the list. This will * be drawn using the same height as the normal divider ({@link #setDivider(Drawable)}) or * if it does not have an intrinsic height, the height set by {@link #setDividerHeight(int)}. - * + * * @param childDivider The drawable to use. */ public void setChildDivider(Drawable childDivider) { @@ -520,7 +520,7 @@ public class ExpandableListView extends ListView { @Override void drawDivider(Canvas canvas, Rect bounds, int childIndex) { int flatListPosition = childIndex + mFirstPosition; - + // Only proceed as possible child if the divider isn't above all items (if it is above // all items, then the item below it has to be a group) if (flatListPosition >= 0) { @@ -538,7 +538,7 @@ public class ExpandableListView extends ListView { } pos.recycle(); } - + // Otherwise draw the default divider super.drawDivider(canvas, bounds, flatListPosition); } @@ -589,18 +589,18 @@ public class ExpandableListView extends ListView { public void setAdapter(ExpandableListAdapter adapter) { // Set member variable mAdapter = adapter; - + if (adapter != null) { // Create the connector mConnector = new ExpandableListConnector(adapter); } else { mConnector = null; } - + // Link the ListView (superclass) to the expandable list data through the connector super.setAdapter(mConnector); } - + /** * Gets the adapter that provides data to this view. * @return The adapter that provides data to this view. @@ -608,7 +608,7 @@ public class ExpandableListView extends ListView { public ExpandableListAdapter getExpandableListAdapter() { return mAdapter; } - + /** * @param position An absolute (including header and footer) flat list position. * @return true if the position corresponds to a header or a footer item. @@ -621,7 +621,7 @@ public class ExpandableListView extends ListView { /** * Converts an absolute item flat position into a group/child flat position, shifting according * to the number of header items. - * + * * @param flatListPosition The absolute flat position * @return A group/child flat position as expected by the connector. */ @@ -632,7 +632,7 @@ public class ExpandableListView extends ListView { /** * Converts a group/child flat position into an absolute flat position, that takes into account * the possible headers. - * + * * @param flatListPosition The child/group flat position * @return An absolute flat position. */ @@ -647,25 +647,25 @@ public class ExpandableListView extends ListView { // Clicked on a header/footer, so ignore pass it on to super return super.performItemClick(v, position, id); } - + // Internally handle the item click final int adjustedPosition = getFlatPositionForConnector(position); return handleItemClick(v, adjustedPosition, id); } - + /** * This will either expand/collapse groups (if a group was clicked) or pass * on the click to the proper child (if a child was clicked) - * + * * @param position The flat list position. This has already been factored to * remove the header/footer. * @param id The ListAdapter ID, not the group or child ID. */ boolean handleItemClick(View v, int position, long id) { final PositionMetadata posMetadata = mConnector.getUnflattenedPos(position); - + id = getChildOrGroupId(posMetadata.position); - + boolean returnValue; if (posMetadata.position.type == ExpandableListPosition.GROUP) { /* It's a group, so handle collapsing/expanding */ @@ -697,11 +697,11 @@ public class ExpandableListView extends ListView { if (mOnGroupExpandListener != null) { mOnGroupExpandListener.onGroupExpand(posMetadata.position.groupPos); } - + final int groupPos = posMetadata.position.groupPos; final int groupFlatPos = posMetadata.position.flatListPos; - final int shiftedGroupPosition = groupFlatPos + getHeaderViewsCount(); + final int shiftedGroupPosition = groupFlatPos + getHeaderViewsCount(); smoothScrollToPosition(shiftedGroupPosition + mAdapter.getChildrenCount(groupPos), shiftedGroupPosition); } @@ -764,17 +764,17 @@ public class ExpandableListView extends ListView { return retValue; } - + /** * Collapse a group in the grouped list view - * + * * @param groupPos position of the group to collapse * @return True if the group was collapsed, false otherwise (if the group * was already collapsed, this will return false) */ public boolean collapseGroup(int groupPos) { boolean retValue = mConnector.collapseGroup(groupPos); - + if (mOnGroupCollapseListener != null) { mOnGroupCollapseListener.onGroupCollapse(groupPos); } @@ -787,14 +787,14 @@ public class ExpandableListView extends ListView { /** * Callback method to be invoked when a group in this expandable list has * been collapsed. - * + * * @param groupPosition The group position that was collapsed */ void onGroupCollapse(int groupPosition); } - + private OnGroupCollapseListener mOnGroupCollapseListener; - + public void setOnGroupCollapseListener( OnGroupCollapseListener onGroupCollapseListener) { mOnGroupCollapseListener = onGroupCollapseListener; @@ -805,14 +805,14 @@ public class ExpandableListView extends ListView { /** * Callback method to be invoked when a group in this expandable list has * been expanded. - * + * * @param groupPosition The group position that was expanded */ void onGroupExpand(int groupPosition); } - + private OnGroupExpandListener mOnGroupExpandListener; - + public void setOnGroupExpandListener( OnGroupExpandListener onGroupExpandListener) { mOnGroupExpandListener = onGroupExpandListener; @@ -826,7 +826,7 @@ public class ExpandableListView extends ListView { /** * Callback method to be invoked when a group in this expandable list has * been clicked. - * + * * @param parent The ExpandableListConnector where the click happened * @param v The view within the expandable list/ListView that was clicked * @param groupPosition The group position that was clicked @@ -836,13 +836,13 @@ public class ExpandableListView extends ListView { boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id); } - + private OnGroupClickListener mOnGroupClickListener; public void setOnGroupClickListener(OnGroupClickListener onGroupClickListener) { mOnGroupClickListener = onGroupClickListener; } - + /** * Interface definition for a callback to be invoked when a child in this * expandable list has been clicked. @@ -851,7 +851,7 @@ public class ExpandableListView extends ListView { /** * Callback method to be invoked when a child in this expandable list has * been clicked. - * + * * @param parent The ExpandableListView where the click happened * @param v The view within the expandable list/ListView that was clicked * @param groupPosition The group position that contains the child that @@ -863,13 +863,13 @@ public class ExpandableListView extends ListView { boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id); } - + private OnChildClickListener mOnChildClickListener; public void setOnChildClickListener(OnChildClickListener onChildClickListener) { mOnChildClickListener = onChildClickListener; } - + /** * Converts a flat list position (the raw position of an item (child or group) * in the list) to a group and/or child position (represented in a @@ -878,7 +878,7 @@ public class ExpandableListView extends ListView { * {@link ExpandableListView#getPackedPositionType} , * {@link ExpandableListView#getPackedPositionChild}, * {@link ExpandableListView#getPackedPositionGroup} to unpack. - * + * * @param flatListPosition The flat list position to be converted. * @return The group and/or child position for the given flat list position * in packed position representation. #PACKED_POSITION_VALUE_NULL if @@ -895,12 +895,12 @@ public class ExpandableListView extends ListView { pm.recycle(); return packedPos; } - + /** * Converts a group and/or child position to a flat list position. This is * useful in situations where the caller needs to use the underlying * {@link ListView}'s methods. - * + * * @param packedPosition The group and/or child positions to be converted in * packed position representation. Use * {@link #getPackedPositionForChild(int, int)} or @@ -920,7 +920,7 @@ public class ExpandableListView extends ListView { /** * Gets the position of the currently selected group or child (along with * its type). Can return {@link #PACKED_POSITION_VALUE_NULL} if no selection. - * + * * @return A packed position containing the currently selected group or * child's position and type. #PACKED_POSITION_VALUE_NULL if no selection * or if selection is on a header or a footer item. @@ -931,11 +931,11 @@ public class ExpandableListView extends ListView { // The case where there is no selection (selectedPos == -1) is also handled here. return getExpandableListPosition(selectedPos); } - + /** * Gets the ID of the currently selected group or child. Can return -1 if no * selection. - * + * * @return The ID of the currently selected group or child. -1 if no * selection. */ @@ -944,7 +944,7 @@ public class ExpandableListView extends ListView { if (packedPos == PACKED_POSITION_VALUE_NULL) return -1; int groupPos = getPackedPositionGroup(packedPos); - + if (getPackedPositionType(packedPos) == PACKED_POSITION_TYPE_GROUP) { // It's a group return mAdapter.getGroupId(groupPos); @@ -953,7 +953,7 @@ public class ExpandableListView extends ListView { return mAdapter.getChildId(groupPos, getPackedPositionChild(packedPos)); } } - + /** * Sets the selection to the specified group. * @param groupPosition The position of the group that should be selected. @@ -967,12 +967,12 @@ public class ExpandableListView extends ListView { super.setSelection(absoluteFlatPosition); pm.recycle(); } - + /** * Sets the selection to the specified child. If the child is in a collapsed * group, the group will only be expanded and child subsequently selected if * shouldExpandGroup is set to true, otherwise the method will return false. - * + * * @param groupPosition The position of the group that contains the child. * @param childPosition The position of the child within the group. * @param shouldExpandGroup Whether the child's group should be expanded if @@ -981,48 +981,48 @@ public class ExpandableListView extends ListView { */ public boolean setSelectedChild(int groupPosition, int childPosition, boolean shouldExpandGroup) { ExpandableListPosition elChildPos = ExpandableListPosition.obtainChildPosition( - groupPosition, childPosition); + groupPosition, childPosition); PositionMetadata flatChildPos = mConnector.getFlattenedPos(elChildPos); - + if (flatChildPos == null) { // The child's group isn't expanded - + // Shouldn't expand the group, so return false for we didn't set the selection - if (!shouldExpandGroup) return false; + if (!shouldExpandGroup) return false; expandGroup(groupPosition); - + flatChildPos = mConnector.getFlattenedPos(elChildPos); - + // Sanity check if (flatChildPos == null) { throw new IllegalStateException("Could not find child"); } } - + int absoluteFlatPosition = getAbsoluteFlatPosition(flatChildPos.position.flatListPos); super.setSelection(absoluteFlatPosition); - + elChildPos.recycle(); flatChildPos.recycle(); - + return true; } /** * Whether the given group is currently expanded. - * + * * @param groupPosition The group to check. * @return Whether the group is currently expanded. */ public boolean isGroupExpanded(int groupPosition) { return mConnector.isGroupExpanded(groupPosition); } - + /** * Gets the type of a packed position. See * {@link #getPackedPositionForChild(int, int)}. - * + * * @param packedPosition The packed position for which to return the type. * @return The type of the position contained within the packed position, * either {@link #PACKED_POSITION_TYPE_CHILD}, {@link #PACKED_POSITION_TYPE_GROUP}, or @@ -1032,7 +1032,7 @@ public class ExpandableListView extends ListView { if (packedPosition == PACKED_POSITION_VALUE_NULL) { return PACKED_POSITION_TYPE_NULL; } - + return (packedPosition & PACKED_POSITION_MASK_TYPE) == PACKED_POSITION_MASK_TYPE ? PACKED_POSITION_TYPE_CHILD : PACKED_POSITION_TYPE_GROUP; @@ -1041,7 +1041,7 @@ public class ExpandableListView extends ListView { /** * Gets the group position from a packed position. See * {@link #getPackedPositionForChild(int, int)}. - * + * * @param packedPosition The packed position from which the group position * will be returned. * @return The group position portion of the packed position. If this does @@ -1050,7 +1050,7 @@ public class ExpandableListView extends ListView { public static int getPackedPositionGroup(long packedPosition) { // Null if (packedPosition == PACKED_POSITION_VALUE_NULL) return -1; - + return (int) ((packedPosition & PACKED_POSITION_MASK_GROUP) >> PACKED_POSITION_SHIFT_GROUP); } @@ -1060,7 +1060,7 @@ public class ExpandableListView extends ListView { * To get the group that this child belongs to, use * {@link #getPackedPositionGroup(long)}. See * {@link #getPackedPositionForChild(int, int)}. - * + * * @param packedPosition The packed position from which the child position * will be returned. * @return The child position portion of the packed position. If this does @@ -1069,7 +1069,7 @@ public class ExpandableListView extends ListView { public static int getPackedPositionChild(long packedPosition) { // Null if (packedPosition == PACKED_POSITION_VALUE_NULL) return -1; - + // Group since a group type clears this bit if ((packedPosition & PACKED_POSITION_MASK_TYPE) != PACKED_POSITION_MASK_TYPE) return -1; @@ -1087,7 +1087,7 @@ public class ExpandableListView extends ListView { * {@link #getPackedPositionChild(long)}, * {@link #getPackedPositionGroup(long)}, and * {@link #getPackedPositionType(long)}. - * + * * @param groupPosition The child's parent group's position. * @param childPosition The child position within the group. * @return The packed position representation of the child (and parent group). @@ -1096,20 +1096,20 @@ public class ExpandableListView extends ListView { return (((long)PACKED_POSITION_TYPE_CHILD) << PACKED_POSITION_SHIFT_TYPE) | ((((long)groupPosition) & PACKED_POSITION_INT_MASK_GROUP) << PACKED_POSITION_SHIFT_GROUP) - | (childPosition & PACKED_POSITION_INT_MASK_CHILD); + | (childPosition & PACKED_POSITION_INT_MASK_CHILD); } /** * Returns the packed position representation of a group's position. See * {@link #getPackedPositionForChild(int, int)}. - * + * * @param groupPosition The child's parent group's position. * @return The packed position representation of the group. */ public static long getPackedPositionForGroup(int groupPosition) { // No need to OR a type in because PACKED_POSITION_GROUP == 0 return ((((long)groupPosition) & PACKED_POSITION_INT_MASK_GROUP) - << PACKED_POSITION_SHIFT_GROUP); + << PACKED_POSITION_SHIFT_GROUP); } @Override @@ -1122,12 +1122,12 @@ public class ExpandableListView extends ListView { final int adjustedPosition = getFlatPositionForConnector(flatListPosition); PositionMetadata pm = mConnector.getUnflattenedPos(adjustedPosition); ExpandableListPosition pos = pm.position; - + id = getChildOrGroupId(pos); long packedPosition = pos.getPackedPosition(); pm.recycle(); - + return new ExpandableListContextMenuInfo(view, packedPosition, id); } @@ -1135,7 +1135,7 @@ public class ExpandableListView extends ListView { * Gets the ID of the group or child at the given <code>position</code>. * This is useful since there is no ListAdapter ID -> ExpandableListAdapter * ID conversion mechanism (in some cases, it isn't possible). - * + * * @param position The position of the child or group whose ID should be * returned. */ @@ -1146,10 +1146,10 @@ public class ExpandableListView extends ListView { return mAdapter.getGroupId(position.groupPos); } } - + /** * Sets the indicator to be drawn next to a child. - * + * * @param childIndicator The drawable to be used as an indicator. If the * child is the last child for a group, the state * {@link android.R.attr#state_last} will be set. @@ -1157,7 +1157,7 @@ public class ExpandableListView extends ListView { public void setChildIndicator(Drawable childIndicator) { mChildIndicator = childIndicator; } - + /** * Sets the drawing bounds for the child indicator. For either, you can * specify {@link #CHILD_INDICATOR_INHERIT} to use inherit from the general @@ -1194,7 +1194,7 @@ public class ExpandableListView extends ListView { /** * Sets the indicator to be drawn next to a group. - * + * * @param groupIndicator The drawable to be used as an indicator. If the * group is empty, the state {@link android.R.attr#state_empty} will be * set. If the group is expanded, the state @@ -1211,8 +1211,8 @@ public class ExpandableListView extends ListView { * Sets the drawing bounds for the indicators (at minimum, the group indicator * is affected by this; the child indicator is affected by this if the * child indicator bounds are set to inherit). - * - * @see #setChildIndicatorBounds(int, int) + * + * @see #setChildIndicatorBounds(int, int) * @param left The left position (relative to the left bounds of this View) * to start drawing the indicator. * @param right The right position (relative to the left bounds of this @@ -1248,13 +1248,13 @@ public class ExpandableListView extends ListView { * callback when a context menu is brought up for this AdapterView. */ public static class ExpandableListContextMenuInfo implements ContextMenu.ContextMenuInfo { - + public ExpandableListContextMenuInfo(View targetView, long packedPosition, long id) { this.targetView = targetView; this.packedPosition = packedPosition; this.id = id; } - + /** * The view for which the context menu is being displayed. This * will be one of the children Views of this {@link ExpandableListView}. @@ -1276,10 +1276,10 @@ public class ExpandableListView extends ListView { */ public long id; } - + static class SavedState extends BaseSavedState { ArrayList<ExpandableListConnector.GroupMetadata> expandedGroupMetadataList; - + /** * Constructor called from {@link ExpandableListView#onSaveInstanceState()} */ @@ -1333,7 +1333,7 @@ public class ExpandableListView extends ListView { SavedState ss = (SavedState) state; super.onRestoreInstanceState(ss.getSuperState()); - + if (mConnector != null && ss.expandedGroupMetadataList != null) { mConnector.setExpandedGroupMetadataList(ss.expandedGroupMetadataList); } diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java index b8c74d88b580..dc8ee01391b8 100644 --- a/core/java/android/widget/FrameLayout.java +++ b/core/java/android/widget/FrameLayout.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.AttrRes; import android.annotation.NonNull; import android.annotation.Nullable; @@ -34,6 +32,8 @@ import android.view.ViewGroup; import android.view.ViewHierarchyEncoder; import android.widget.RemoteViews.RemoteView; +import com.android.internal.R; + import java.util.ArrayList; /** diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java index af2852cde22a..1c15c7ae7987 100644 --- a/core/java/android/widget/GridLayout.java +++ b/core/java/android/widget/GridLayout.java @@ -16,6 +16,20 @@ package android.widget; +import static android.view.Gravity.AXIS_PULL_AFTER; +import static android.view.Gravity.AXIS_PULL_BEFORE; +import static android.view.Gravity.AXIS_SPECIFIED; +import static android.view.Gravity.AXIS_X_SHIFT; +import static android.view.Gravity.AXIS_Y_SHIFT; +import static android.view.Gravity.HORIZONTAL_GRAVITY_MASK; +import static android.view.Gravity.RELATIVE_LAYOUT_DIRECTION; +import static android.view.Gravity.VERTICAL_GRAVITY_MASK; +import static android.view.View.MeasureSpec.EXACTLY; +import static android.view.View.MeasureSpec.makeMeasureSpec; + +import static java.lang.Math.max; +import static java.lang.Math.min; + import android.annotation.IntDef; import android.content.Context; import android.content.res.TypedArray; @@ -32,6 +46,7 @@ import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.RemoteViews.RemoteView; + import com.android.internal.R; import java.lang.annotation.Retention; @@ -43,12 +58,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static android.view.Gravity.*; -import static android.view.View.MeasureSpec.EXACTLY; -import static android.view.View.MeasureSpec.makeMeasureSpec; -import static java.lang.Math.max; -import static java.lang.Math.min; - /** * A layout that places its children in a rectangular <em>grid</em>. * <p> diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index b95aa52c11e9..20543fb9ae8a 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -36,9 +36,9 @@ import android.view.ViewHierarchyEncoder; import android.view.ViewRootImpl; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; -import android.view.accessibility.AccessibilityNodeProvider; import android.view.accessibility.AccessibilityNodeInfo.CollectionInfo; import android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo; +import android.view.accessibility.AccessibilityNodeProvider; import android.view.animation.GridLayoutAnimationController; import android.widget.RemoteViews.RemoteView; @@ -54,7 +54,7 @@ import java.lang.annotation.RetentionPolicy; * * <p>See the <a href="{@docRoot}guide/topics/ui/layout/gridview.html">Grid * View</a> guide.</p> - * + * * @attr ref android.R.styleable#GridView_horizontalSpacing * @attr ref android.R.styleable#GridView_verticalSpacing * @attr ref android.R.styleable#GridView_stretchMode @@ -71,33 +71,33 @@ public class GridView extends AbsListView { /** * Disables stretching. - * - * @see #setStretchMode(int) + * + * @see #setStretchMode(int) */ public static final int NO_STRETCH = 0; /** * Stretches the spacing between columns. - * - * @see #setStretchMode(int) + * + * @see #setStretchMode(int) */ public static final int STRETCH_SPACING = 1; /** * Stretches columns. - * - * @see #setStretchMode(int) + * + * @see #setStretchMode(int) */ public static final int STRETCH_COLUMN_WIDTH = 2; /** * Stretches the spacing between columns. The spacing is uniform. - * - * @see #setStretchMode(int) + * + * @see #setStretchMode(int) */ public static final int STRETCH_SPACING_UNIFORM = 3; /** * Creates as many columns as can fit on screen. - * - * @see #setNumColumns(int) + * + * @see #setNumColumns(int) */ public static final int AUTO_FIT = -1; @@ -161,7 +161,7 @@ public class GridView extends AbsListView { if (index >= 0) { setGravity(index); } - + a.recycle(); } @@ -192,7 +192,7 @@ public class GridView extends AbsListView { } resetList(); - mRecycler.clear(); + mRecycler.clear(); mAdapter = adapter; mOldSelectedPosition = INVALID_POSITION; @@ -222,7 +222,7 @@ public class GridView extends AbsListView { setNextSelectedPositionInt(position); checkSelectionChanged(); } else { - checkFocus(); + checkFocus(); // Nothing selected checkSelectionChanged(); } @@ -376,7 +376,7 @@ public class GridView extends AbsListView { } mReferenceView = child; - + if (selectedView != null) { mReferenceViewInSelectedRow = mReferenceView; } @@ -515,7 +515,7 @@ public class GridView extends AbsListView { offsetChildrenTopAndBottom(offset); } } - } + } @Override int findMotionRow(int y) { @@ -624,7 +624,7 @@ public class GridView extends AbsListView { // This is how far the bottom edge of the last view is from the bottom of the // drawable area - int bottomOffset = end - lastBottom; + int bottomOffset = end - lastBottom; final View firstChild = getChildAt(0); final int firstTop = firstChild.getTop(); @@ -636,7 +636,7 @@ public class GridView extends AbsListView { // Don't pull the top too far down bottomOffset = Math.min(bottomOffset, mListPadding.top - firstTop); } - + // Move everything down offsetChildrenTopAndBottom(bottomOffset); if (mFirstPosition > 0) { @@ -679,7 +679,7 @@ public class GridView extends AbsListView { // Don't pull the bottom too far up topOffset = Math.min(topOffset, lastBottom - end); } - + // Move everything up offsetChildrenTopAndBottom(-topOffset); if (lastPosition < mItemCount - 1) { @@ -965,7 +965,7 @@ public class GridView extends AbsListView { final int stretchMode = mStretchMode; final int requestedColumnWidth = mRequestedColumnWidth; boolean didNotInitiallyFit = false; - + if (mRequestedNumColumns == AUTO_FIT) { if (requestedColumnWidth > 0) { // Client told us to pick the number of columns @@ -979,57 +979,57 @@ public class GridView extends AbsListView { // We picked the columns mNumColumns = mRequestedNumColumns; } - + if (mNumColumns <= 0) { mNumColumns = 1; } switch (stretchMode) { - case NO_STRETCH: - // Nobody stretches - mColumnWidth = requestedColumnWidth; - mHorizontalSpacing = requestedHorizontalSpacing; - break; - - default: - int spaceLeftOver = availableSpace - (mNumColumns * requestedColumnWidth) - - ((mNumColumns - 1) * requestedHorizontalSpacing); - - if (spaceLeftOver < 0) { - didNotInitiallyFit = true; - } - - switch (stretchMode) { - case STRETCH_COLUMN_WIDTH: - // Stretch the columns - mColumnWidth = requestedColumnWidth + spaceLeftOver / mNumColumns; + case NO_STRETCH: + // Nobody stretches + mColumnWidth = requestedColumnWidth; mHorizontalSpacing = requestedHorizontalSpacing; break; - case STRETCH_SPACING: - // Stretch the spacing between columns - mColumnWidth = requestedColumnWidth; - if (mNumColumns > 1) { - mHorizontalSpacing = requestedHorizontalSpacing + - spaceLeftOver / (mNumColumns - 1); - } else { - mHorizontalSpacing = requestedHorizontalSpacing + spaceLeftOver; + default: + int spaceLeftOver = availableSpace - (mNumColumns * requestedColumnWidth) + - ((mNumColumns - 1) * requestedHorizontalSpacing); + + if (spaceLeftOver < 0) { + didNotInitiallyFit = true; } - break; - case STRETCH_SPACING_UNIFORM: - // Stretch the spacing between columns - mColumnWidth = requestedColumnWidth; - if (mNumColumns > 1) { - mHorizontalSpacing = requestedHorizontalSpacing + - spaceLeftOver / (mNumColumns + 1); - } else { - mHorizontalSpacing = requestedHorizontalSpacing + spaceLeftOver; + switch (stretchMode) { + case STRETCH_COLUMN_WIDTH: + // Stretch the columns + mColumnWidth = requestedColumnWidth + spaceLeftOver / mNumColumns; + mHorizontalSpacing = requestedHorizontalSpacing; + break; + + case STRETCH_SPACING: + // Stretch the spacing between columns + mColumnWidth = requestedColumnWidth; + if (mNumColumns > 1) { + mHorizontalSpacing = requestedHorizontalSpacing + + spaceLeftOver / (mNumColumns - 1); + } else { + mHorizontalSpacing = requestedHorizontalSpacing + spaceLeftOver; + } + break; + + case STRETCH_SPACING_UNIFORM: + // Stretch the spacing between columns + mColumnWidth = requestedColumnWidth; + if (mNumColumns > 1) { + mHorizontalSpacing = requestedHorizontalSpacing + + spaceLeftOver / (mNumColumns + 1); + } else { + mHorizontalSpacing = requestedHorizontalSpacing + spaceLeftOver; + } + break; } - break; - } - break; + break; } return didNotInitiallyFit; } @@ -1052,7 +1052,7 @@ public class GridView extends AbsListView { } widthSize += getVerticalScrollbarWidth(); } - + int childWidth = widthSize - mListPadding.left - mListPadding.right; boolean didNotInitiallyFit = determineColumns(childWidth); @@ -1087,7 +1087,7 @@ public class GridView extends AbsListView { mRecycler.addScrapView(child, -1); } } - + if (heightMode == MeasureSpec.UNSPECIFIED) { heightSize = mListPadding.top + mListPadding.bottom + childHeight + getVerticalFadingEdgeLength() * 2; @@ -1095,7 +1095,7 @@ public class GridView extends AbsListView { if (heightMode == MeasureSpec.AT_MOST) { int ourSize = mListPadding.top + mListPadding.bottom; - + final int numColumns = mNumColumns; for (int i = 0; i < count; i += numColumns) { ourSize += childHeight; @@ -1574,9 +1574,9 @@ public class GridView extends AbsListView { /** * Sets the currently selected item - * + * * @param position Index (starting at 0) of the data item to be selected. - * + * * If in touch mode, the item will not be selected but it will still be positioned * appropriately. */ @@ -1609,8 +1609,8 @@ public class GridView extends AbsListView { setNextSelectedPositionInt(position); layoutChildren(); - - final int next = mStackFromBottom ? mItemCount - 1 - mNextSelectedPosition : + + final int next = mStackFromBottom ? mItemCount - 1 - mNextSelectedPosition : mNextSelectedPosition; final int previous = mStackFromBottom ? mItemCount - 1 - previousSelectedPosition : previousSelectedPosition; @@ -1802,7 +1802,7 @@ public class GridView extends AbsListView { invokeOnItemScrollListener(); moved = true; } - + if (moved) { awakenScrollBars(); } @@ -1874,7 +1874,7 @@ public class GridView extends AbsListView { if (moved) { awakenScrollBars(); } - + return moved; } @@ -2216,17 +2216,17 @@ public class GridView extends AbsListView { requestLayoutIfNecessary(); } } - + /** - * Get the number of columns in the grid. + * Get the number of columns in the grid. * Returns {@link #AUTO_FIT} if the Grid has never been laid out. * * @attr ref android.R.styleable#GridView_numColumns - * + * * @see #setNumColumns(int) */ @ViewDebug.ExportedProperty - public int getNumColumns() { + public int getNumColumns() { return mNumColumns; } @@ -2259,13 +2259,13 @@ public class GridView extends AbsListView { // we are too high, slide all views down to align with bottom child = getChildAt(childCount - 1); delta = child.getBottom() - (getHeight() - mListPadding.bottom); - + if (mFirstPosition + childCount < mItemCount) { // It's OK to have some space below the last item if it is // part of the vertical spacing delta += mVerticalSpacing; } - + if (delta > 0) { // We only are looking to see if we are too high, not too low delta = 0; @@ -2277,14 +2277,14 @@ public class GridView extends AbsListView { } } } - + @Override protected int computeVerticalScrollExtent() { final int count = getChildCount(); if (count > 0) { final int numColumns = mNumColumns; final int rowCount = (count + numColumns - 1) / numColumns; - + int extent = rowCount * 100; View view = getChildAt(0); diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index 6511de81b6cb..544e591158cf 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; @@ -34,15 +32,17 @@ import android.view.ViewGroup; import android.view.ViewHierarchyEncoder; import android.widget.RemoteViews.RemoteView; +import com.android.internal.R; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** - * A Layout that arranges its children in a single column or a single row. The direction of - * the row can be set by calling {@link #setOrientation(int) setOrientation()}. + * A Layout that arranges its children in a single column or a single row. The direction of + * the row can be set by calling {@link #setOrientation(int) setOrientation()}. * You can also specify gravity, which specifies the alignment of all the child elements by - * calling {@link #setGravity(int) setGravity()} or specify that specific children + * calling {@link #setGravity(int) setGravity()} or specify that specific children * grow to fill up any remaining space in the layout by setting the <em>weight</em> member of * {@link android.widget.LinearLayout.LayoutParams LinearLayout.LayoutParams}. * The default orientation is horizontal. @@ -202,7 +202,7 @@ public class LinearLayout extends ViewGroup { public LinearLayout(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } - + public LinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } @@ -497,7 +497,7 @@ public class LinearLayout extends ViewGroup { * When true, all children with a weight will be considered having * the minimum size of the largest child. If false, all children are * measured normally. - * + * * @return True to measure children with a weight using the minimum * size of the largest child, false otherwise. * @@ -511,9 +511,9 @@ public class LinearLayout extends ViewGroup { * When set to true, all children with a weight will be considered having * the minimum size of the largest child. If false, all children are * measured normally. - * + * * Disabled by default. - * + * * @param enabled True to measure children with a weight using the * minimum size of the largest child, false otherwise. * @@ -589,7 +589,7 @@ public class LinearLayout extends ViewGroup { /** * @param i The index of the child that will be used if this layout is * part of a larger layout that is baseline aligned. - * + * * @attr ref android.R.styleable#LinearLayout_baselineAlignedChildIndex */ @android.view.RemotableViewMethod @@ -720,14 +720,14 @@ public class LinearLayout extends ViewGroup { float totalWeight = 0; final int count = getVirtualChildCount(); - + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); final int heightMode = MeasureSpec.getMode(heightMeasureSpec); boolean matchWidth = false; boolean skippedMeasure = false; - final int baselineChildIndex = mBaselineAlignedChildIndex; + final int baselineChildIndex = mBaselineAlignedChildIndex; final boolean useLargestChild = mUseLargestChild; int largestChildHeight = Integer.MIN_VALUE; @@ -886,7 +886,7 @@ public class LinearLayout extends ViewGroup { // Check against our minimum height heightSize = Math.max(heightSize, getSuggestedMinimumHeight()); - + // Reconcile our calculated size with the heightMeasureSpec int heightSizeAndState = resolveSizeAndState(heightSize, heightMeasureSpec, 0); heightSize = heightSizeAndState & MEASURED_SIZE_MASK; @@ -991,12 +991,12 @@ public class LinearLayout extends ViewGroup { if (!allFillParent && widthMode != MeasureSpec.EXACTLY) { maxWidth = alternativeMaxWidth; } - + maxWidth += mPaddingLeft + mPaddingRight; // Check against our minimum width maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth()); - + setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState), heightSizeAndState); @@ -1013,13 +1013,13 @@ public class LinearLayout extends ViewGroup { final View child = getVirtualChildAt(i); if (child != null && child.getVisibility() != GONE) { LinearLayout.LayoutParams lp = ((LinearLayout.LayoutParams)child.getLayoutParams()); - + if (lp.width == LayoutParams.MATCH_PARENT) { // Temporarily force children to reuse their old measured height // FIXME: this may not be right for something like wrapping text? int oldHeight = lp.height; lp.height = child.getMeasuredHeight(); - + // Remeasue with new dimensions measureChildWithMargins(child, uniformMeasureSpec, 0, heightMeasureSpec, 0); lp.height = oldHeight; @@ -1037,7 +1037,7 @@ public class LinearLayout extends ViewGroup { * * @see #getOrientation() * @see #setOrientation(int) - * @see #onMeasure(int, int) + * @see #onMeasure(int, int) */ void measureHorizontal(int widthMeasureSpec, int heightMeasureSpec) { mTotalLength = 0; @@ -1049,7 +1049,7 @@ public class LinearLayout extends ViewGroup { float totalWeight = 0; final int count = getVirtualChildCount(); - + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); final int heightMode = MeasureSpec.getMode(heightMeasureSpec); @@ -1069,7 +1069,7 @@ public class LinearLayout extends ViewGroup { final boolean baselineAligned = mBaselineAligned; final boolean useLargestChild = mUseLargestChild; - + final boolean isExactly = widthMode == MeasureSpec.EXACTLY; int largestChildWidth = Integer.MIN_VALUE; @@ -1084,7 +1084,7 @@ public class LinearLayout extends ViewGroup { mTotalLength += measureNullChild(i); continue; } - + if (child.getVisibility() == GONE) { i += getChildrenSkipCount(child, i); continue; @@ -1263,16 +1263,16 @@ public class LinearLayout extends ViewGroup { // Add in our padding mTotalLength += mPaddingLeft + mPaddingRight; - + int widthSize = mTotalLength; - + // Check against our minimum width widthSize = Math.max(widthSize, getSuggestedMinimumWidth()); - + // Reconcile our calculated size with the widthMeasureSpec int widthSizeAndState = resolveSizeAndState(widthSize, widthMeasureSpec, 0); widthSize = widthSizeAndState & MEASURED_SIZE_MASK; - + // Either expand children with weight to take up available space or // shrink them if they extend beyond our current bounds. If we skipped // measurement on any children, we need to measure them now. @@ -1409,12 +1409,12 @@ public class LinearLayout extends ViewGroup { if (!allFillParent && heightMode != MeasureSpec.EXACTLY) { maxHeight = alternativeMaxHeight; } - + maxHeight += mPaddingTop + mPaddingBottom; // Check against our minimum height maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight()); - + setMeasuredDimension(widthSizeAndState | (childState&MEASURED_STATE_MASK), resolveSizeAndState(maxHeight, heightMeasureSpec, (childState<<MEASURED_HEIGHT_STATE_SHIFT))); @@ -1434,13 +1434,13 @@ public class LinearLayout extends ViewGroup { final View child = getVirtualChildAt(i); if (child != null && child.getVisibility() != GONE) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) child.getLayoutParams(); - + if (lp.height == LayoutParams.MATCH_PARENT) { // Temporarily force children to reuse their old measured width // FIXME: this may not be right for something like wrapping text? int oldWidth = lp.width; lp.width = child.getMeasuredWidth(); - + // Remeasure with new dimensions measureChildWithMargins(child, widthMeasureSpec, 0, uniformMeasureSpec, 0); lp.width = oldWidth; @@ -1541,14 +1541,14 @@ public class LinearLayout extends ViewGroup { int childTop; int childLeft; - + // Where right end of child should go final int width = right - left; int childRight = width - mPaddingRight; - + // Space available for child int childSpace = width - paddingLeft - mPaddingRight; - + final int count = getVirtualChildCount(); final int majorGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK; @@ -1578,10 +1578,10 @@ public class LinearLayout extends ViewGroup { } else if (child.getVisibility() != GONE) { final int childWidth = child.getMeasuredWidth(); final int childHeight = child.getMeasuredHeight(); - + final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) child.getLayoutParams(); - + int gravity = lp.gravity; if (gravity < 0) { gravity = minorGravity; @@ -1647,11 +1647,11 @@ public class LinearLayout extends ViewGroup { int childTop; int childLeft; - + // Where bottom of child should go final int height = bottom - top; - int childBottom = height - mPaddingBottom; - + int childBottom = height - mPaddingBottom; + // Space available for child int childSpace = height - paddingTop - mPaddingBottom; @@ -1707,12 +1707,12 @@ public class LinearLayout extends ViewGroup { if (baselineAligned && lp.height != LayoutParams.MATCH_PARENT) { childBaseline = child.getBaseline(); } - + int gravity = lp.gravity; if (gravity < 0) { gravity = minorGravity; } - + switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.TOP: childTop = paddingTop + lp.topMargin; @@ -1764,15 +1764,15 @@ public class LinearLayout extends ViewGroup { } } - private void setChildFrame(View child, int left, int top, int width, int height) { + private void setChildFrame(View child, int left, int top, int width, int height) { child.layout(left, top, left + width, top + height); } - + /** * Should the layout be a column or a row. * @param orientation Pass {@link #HORIZONTAL} or {@link #VERTICAL}. Default * value is {@link #HORIZONTAL}. - * + * * @attr ref android.R.styleable#LinearLayout_orientation */ public void setOrientation(@OrientationMode int orientation) { @@ -1784,7 +1784,7 @@ public class LinearLayout extends ViewGroup { /** * Returns the current orientation. - * + * * @return either {@link #HORIZONTAL} or {@link #VERTICAL} */ @OrientationMode @@ -1797,9 +1797,9 @@ public class LinearLayout extends ViewGroup { * this layout has a VERTICAL orientation, this controls where all the child * views are placed if there is extra vertical space. If this layout has a * HORIZONTAL orientation, this controls the alignment of the children. - * + * * @param gravity See {@link android.view.Gravity} - * + * * @attr ref android.R.styleable#LinearLayout_gravity */ @android.view.RemotableViewMethod @@ -1845,7 +1845,7 @@ public class LinearLayout extends ViewGroup { requestLayout(); } } - + @Override public LayoutParams generateLayoutParams(AttributeSet attrs) { return new LinearLayout.LayoutParams(getContext(), attrs); @@ -1909,7 +1909,7 @@ public class LinearLayout extends ViewGroup { /** * Per-child layout information associated with ViewLinearLayout. - * + * * @attr ref android.R.styleable#LinearLayout_Layout_layout_weight * @attr ref android.R.styleable#LinearLayout_Layout_layout_gravity */ diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java index 6a10743c1c56..0bde983337f1 100644 --- a/core/java/android/widget/ListPopupWindow.java +++ b/core/java/android/widget/ListPopupWindow.java @@ -16,9 +16,6 @@ package android.widget; -import com.android.internal.R; -import com.android.internal.view.menu.ShowableListMenu; - import android.annotation.AttrRes; import android.annotation.NonNull; import android.annotation.Nullable; @@ -42,14 +39,17 @@ import android.view.ViewParent; import android.view.WindowManager; import android.widget.AdapterView.OnItemSelectedListener; +import com.android.internal.R; +import com.android.internal.view.menu.ShowableListMenu; + /** * A ListPopupWindow anchors itself to a host view and displays a * list of choices. - * + * * <p>ListPopupWindow contains a number of tricky behaviors surrounding * positioning, scrolling parents to fit the dropdown, interacting * sanely with the IME if present, and others. - * + * * @see android.widget.AutoCompleteTextView * @see android.widget.Spinner */ @@ -116,7 +116,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * The provided prompt view should appear above list content. - * + * * @see #setPromptPosition(int) * @see #getPromptPosition() * @see #setPromptView(View) @@ -125,7 +125,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * The provided prompt view should appear below list content. - * + * * @see #setPromptPosition(int) * @see #getPromptPosition() * @see #setPromptView(View) @@ -138,13 +138,13 @@ public class ListPopupWindow implements ShowableListMenu { * If used to specify a popup height, the popup will fill available space. */ public static final int MATCH_PARENT = ViewGroup.LayoutParams.MATCH_PARENT; - + /** * Alias for {@link ViewGroup.LayoutParams#WRAP_CONTENT}. * If used to specify a popup width, the popup will use the width of its content. */ public static final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT; - + /** * Mode for {@link #setInputMethodMode(int)}: the requirements for the * input method should be based on the focusability of the popup. That is @@ -152,7 +152,7 @@ public class ListPopupWindow implements ShowableListMenu { * it doesn't. */ public static final int INPUT_METHOD_FROM_FOCUSABLE = PopupWindow.INPUT_METHOD_FROM_FOCUSABLE; - + /** * Mode for {@link #setInputMethodMode(int)}: this popup always needs to * work with an input method, regardless of whether it is focusable. This @@ -160,7 +160,7 @@ public class ListPopupWindow implements ShowableListMenu { * the input method while it is shown. */ public static final int INPUT_METHOD_NEEDED = PopupWindow.INPUT_METHOD_NEEDED; - + /** * Mode for {@link #setInputMethodMode(int)}: this popup never needs to * work with an input method, regardless of whether it is focusable. This @@ -172,7 +172,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Create a new, empty popup window capable of displaying items from a ListAdapter. * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. - * + * * @param context Context used for contained views. */ public ListPopupWindow(@NonNull Context context) { @@ -182,7 +182,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Create a new, empty popup window capable of displaying items from a ListAdapter. * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. - * + * * @param context Context used for contained views. * @param attrs Attributes from inflating parent views used to style the popup. */ @@ -193,7 +193,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Create a new, empty popup window capable of displaying items from a ListAdapter. * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. - * + * * @param context Context used for contained views. * @param attrs Attributes from inflating parent views used to style the popup. * @param defStyleAttr Default style attribute to use for popup content. @@ -206,7 +206,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Create a new, empty popup window capable of displaying items from a ListAdapter. * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. - * + * * @param context Context used for contained views. * @param attrs Attributes from inflating parent views used to style the popup. * @param defStyleAttr Style attribute to read for default styling of popup content. @@ -248,7 +248,7 @@ public class ListPopupWindow implements ShowableListMenu { if (mAdapter != null) { adapter.registerDataSetObserver(mObserver); } - + if (mDropDownList != null) { mDropDownList.setAdapter(mAdapter); } @@ -257,9 +257,9 @@ public class ListPopupWindow implements ShowableListMenu { /** * Set where the optional prompt view should appear. The default is * {@link #POSITION_PROMPT_ABOVE}. - * + * * @param position A position constant declaring where the prompt should be displayed. - * + * * @see #POSITION_PROMPT_ABOVE * @see #POSITION_PROMPT_BELOW */ @@ -269,7 +269,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * @return Where the optional prompt view should appear. - * + * * @see #POSITION_PROMPT_ABOVE * @see #POSITION_PROMPT_BELOW */ @@ -279,11 +279,11 @@ public class ListPopupWindow implements ShowableListMenu { /** * Set whether this window should be modal when shown. - * + * * <p>If a popup window is modal, it will receive all touch and key input. * If the user touches outside the popup window's content area the popup window * will be dismissed. - * + * * @param modal {@code true} if the popup window should be modal, {@code false} otherwise. */ public void setModal(boolean modal) { @@ -293,7 +293,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Returns whether the popup window will be modal when shown. - * + * * @return {@code true} if the popup window will be modal, {@code false} otherwise. */ public boolean isModal() { @@ -304,7 +304,7 @@ public class ListPopupWindow implements ShowableListMenu { * Forces outside touches to be ignored. Normally if {@link #isDropDownAlwaysVisible()} is * false, we allow outside touch to dismiss the dropdown. If this is set to true, then we * ignore outside touch even when the drop down is not set to always visible. - * + * * @hide Used only by AutoCompleteTextView to handle some internal special cases. */ public void setForceIgnoreOutsideTouch(boolean forceIgnoreOutsideTouch) { @@ -361,7 +361,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Sets a drawable to use as the list item selector. - * + * * @param selector List selector drawable to use in the popup. */ public void setListSelector(Drawable selector) { @@ -377,7 +377,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Sets a drawable to be the background for the popup window. - * + * * @param d A drawable to set as the background. */ public void setBackgroundDrawable(@Nullable Drawable d) { @@ -386,7 +386,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Set an animation style to use when the popup window is shown or dismissed. - * + * * @param animationStyle Animation style to use. */ public void setAnimationStyle(@StyleRes int animationStyle) { @@ -396,7 +396,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Returns the animation style that will be used when the popup window is * shown or dismissed. - * + * * @return Animation style that will be used. */ public @StyleRes int getAnimationStyle() { @@ -405,7 +405,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Returns the view that will be used to anchor this popup. - * + * * @return The popup's anchor view */ public @Nullable View getAnchorView() { @@ -415,7 +415,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Sets the popup's anchor view. This popup will always be positioned relative to * the anchor view when shown. - * + * * @param anchor The view to use as an anchor. */ public void setAnchorView(@Nullable View anchor) { @@ -431,7 +431,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Set the horizontal offset of this popup from its anchor view in pixels. - * + * * @param offset The horizontal offset of the popup from its anchor. */ public void setHorizontalOffset(int offset) { @@ -450,7 +450,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Set the vertical offset of this popup from its anchor view in pixels. - * + * * @param offset The vertical offset of the popup from its anchor. */ public void setVerticalOffset(int offset) { @@ -489,7 +489,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Sets the width of the popup window in pixels. Can also be {@link #MATCH_PARENT} * or {@link #WRAP_CONTENT}. - * + * * @param width Width of the popup window. */ public void setWidth(int width) { @@ -521,7 +521,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Sets the height of the popup window in pixels. Can also be {@link #MATCH_PARENT}. - * + * * @param height Height of the popup window. */ public void setHeight(int height) { @@ -543,9 +543,9 @@ public class ListPopupWindow implements ShowableListMenu { /** * Sets a listener to receive events when a list item is clicked. - * + * * @param clickListener Listener to register - * + * * @see ListView#setOnItemClickListener(android.widget.AdapterView.OnItemClickListener) */ public void setOnItemClickListener(@Nullable AdapterView.OnItemClickListener clickListener) { @@ -554,9 +554,9 @@ public class ListPopupWindow implements ShowableListMenu { /** * Sets a listener to receive events when a list item is selected. - * + * * @param selectedListener Listener to register. - * + * * @see ListView#setOnItemSelectedListener(OnItemSelectedListener) */ public void setOnItemSelectedListener(@Nullable OnItemSelectedListener selectedListener) { @@ -566,7 +566,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Set a view to act as a user prompt for this popup window. Where the prompt view will appear * is controlled by {@link #setPromptPosition(int)}. - * + * * @param prompt View to use as an informational prompt. */ public void setPromptView(@Nullable View prompt) { @@ -662,7 +662,7 @@ public class ListPopupWindow implements ShowableListMenu { mPopup.setWidth(widthSpec); mPopup.setHeight(heightSpec); mPopup.setClipToScreenEnabled(true); - + // use outside touchable to dismiss drop down when touching outside of it, so // only set this if the dropdown is not always visible mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible); @@ -671,7 +671,7 @@ public class ListPopupWindow implements ShowableListMenu { mPopup.showAsDropDown(getAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, mDropDownGravity); mDropDownList.setSelection(ListView.INVALID_POSITION); - + if (!mModal || mDropDownList.isInTouchMode()) { clearListSelection(); } @@ -716,11 +716,11 @@ public class ListPopupWindow implements ShowableListMenu { * Control how the popup operates with an input method: one of * {@link #INPUT_METHOD_FROM_FOCUSABLE}, {@link #INPUT_METHOD_NEEDED}, * or {@link #INPUT_METHOD_NOT_NEEDED}. - * + * * <p>If the popup is showing, calling this method will take effect only * the next time the popup is shown or through a manual call to the {@link #show()} * method.</p> - * + * * @see #getInputMethodMode() * @see #show() */ @@ -730,7 +730,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Return the current value in {@link #setInputMethodMode(int)}. - * + * * @see #setInputMethodMode(int) */ public int getInputMethodMode() { @@ -740,7 +740,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Set the selected position of the list. * Only valid when {@link #isShowing()} == {@code true}. - * + * * @param position List position to set as selected. */ public void setSelection(int position) { @@ -786,7 +786,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * Perform an item click operation on the specified list adapter position. - * + * * @param position Adapter position for performing the click * @return true if the click action could be performed, false if not. * (e.g. if the popup was not showing, this method would return false.) @@ -817,7 +817,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * @return The position of the currently selected item or {@link ListView#INVALID_POSITION} * if {@link #isShowing()} == {@code false}. - * + * * @see ListView#getSelectedItemPosition() */ public int getSelectedItemPosition() { @@ -830,7 +830,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * @return The ID of the currently selected item or {@link ListView#INVALID_ROW_ID} * if {@link #isShowing()} == {@code false}. - * + * * @see ListView#getSelectedItemId() */ public long getSelectedItemId() { @@ -843,7 +843,7 @@ public class ListPopupWindow implements ShowableListMenu { /** * @return The View for the currently selected item or null if * {@link #isShowing()} == {@code false}. - * + * * @see ListView#getSelectedView() */ public @Nullable View getSelectedView() { @@ -904,7 +904,7 @@ public class ListPopupWindow implements ShowableListMenu { final boolean below = !mPopup.isAboveAnchor(); final ListAdapter adapter = mAdapter; - + boolean allEnabled; int firstItem = Integer.MAX_VALUE; int lastItem = Integer.MIN_VALUE; @@ -914,9 +914,9 @@ public class ListPopupWindow implements ShowableListMenu { firstItem = allEnabled ? 0 : mDropDownList.lookForSelectablePosition(0, true); lastItem = allEnabled ? adapter.getCount() - 1 : - mDropDownList.lookForSelectablePosition(adapter.getCount() - 1, false); + mDropDownList.lookForSelectablePosition(adapter.getCount() - 1, false); } - + if ((below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex <= firstItem) || (!below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN && curIndex >= lastItem)) { // When the selection is at the top, we block the key @@ -1132,18 +1132,18 @@ public class ListPopupWindow implements ShowableListMenu { LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f ); - + switch (mPromptPosition) { case POSITION_PROMPT_BELOW: hintContainer.addView(dropDownView, hintParams); hintContainer.addView(hintView); break; - + case POSITION_PROMPT_ABOVE: hintContainer.addView(hintView); hintContainer.addView(dropDownView, hintParams); break; - + default: Log.e(TAG, "Invalid hint position " + mPromptPosition); break; @@ -1249,7 +1249,7 @@ public class ListPopupWindow implements ShowableListMenu { show(); } } - + @Override public void onInvalidated() { dismiss(); @@ -1278,7 +1278,7 @@ public class ListPopupWindow implements ShowableListMenu { final int action = event.getAction(); final int x = (int) event.getX(); final int y = (int) event.getY(); - + if (action == MotionEvent.ACTION_DOWN && mPopup != null && mPopup.isShowing() && (x >= 0 && x < mPopup.getWidth() && y >= 0 && y < mPopup.getHeight())) { diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index b0f19d7a0b49..e88c7efe43c8 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -16,11 +16,6 @@ package android.widget; -import com.google.android.collect.Lists; - -import com.android.internal.R; -import com.android.internal.util.Predicate; - import android.annotation.IdRes; import android.annotation.NonNull; import android.annotation.Nullable; @@ -53,6 +48,11 @@ import android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo; import android.view.accessibility.AccessibilityNodeProvider; import android.widget.RemoteViews.RemoteView; +import com.android.internal.R; +import com.android.internal.util.Predicate; + +import com.google.android.collect.Lists; + import java.util.ArrayList; import java.util.List; @@ -464,7 +464,7 @@ public class ListView extends AbsListView { * data backing this list and for producing a view to represent an * item in that data set. * - * @see #getAdapter() + * @see #getAdapter() */ @Override public void setAdapter(ListAdapter adapter) { @@ -1532,7 +1532,7 @@ public class ListView extends AbsListView { adjustViewsUpOrDown(); } } else if (lastPosition == mItemCount - 1) { - adjustViewsUpOrDown(); + adjustViewsUpOrDown(); } } } @@ -1857,7 +1857,7 @@ public class ListView extends AbsListView { && focusLayoutRestoreView.getWindowToken() != null) { focusLayoutRestoreView.dispatchFinishTemporaryDetach(); } - + mLayoutMode = LAYOUT_NORMAL; mDataChanged = false; if (mPositionScrollAfterLayout != null) { @@ -2109,7 +2109,7 @@ public class ListView extends AbsListView { /** * Makes the item at the supplied position selected. - * + * * @param position the position of the item to select */ @Override @@ -2960,7 +2960,7 @@ public class ListView extends AbsListView { if (startPos < firstPosition) { startPos = firstPosition; } - + final int lastVisiblePos = getLastVisiblePosition(); final ListAdapter adapter = getAdapter(); for (int pos = startPos; pos <= lastVisiblePos; pos++) { @@ -3129,7 +3129,7 @@ public class ListView extends AbsListView { /** * Determine the distance to the nearest edge of a view in a particular * direction. - * + * * @param descendant A descendant of this list. * @return The distance, or 0 if the nearest edge is already on screen. */ @@ -3386,7 +3386,7 @@ public class ListView extends AbsListView { final int listBottom = mBottom - mTop - effectivePaddingBottom + mScrollY; if (!mStackFromBottom) { int bottom = 0; - + // Draw top divider or header for overscroll final int scrollY = mScrollY; if (count > 0 && scrollY < 0) { @@ -3483,7 +3483,7 @@ public class ListView extends AbsListView { } } } - + if (count > 0 && scrollY > 0) { if (drawOverscrollFooter) { final int absListBottom = mBottom; @@ -3567,7 +3567,7 @@ public class ListView extends AbsListView { public int getDividerHeight() { return mDividerHeight; } - + /** * Sets the height of the divider that will be drawn between each item in the list. Calling * this will override the intrinsic height as set by {@link #setDivider(Drawable)} @@ -3625,7 +3625,7 @@ public class ListView extends AbsListView { public boolean areFooterDividersEnabled() { return mFooterDividersEnabled; } - + /** * Sets the drawable that will be drawn above all other list content. * This area can become visible when the user overscrolls the list. @@ -3878,10 +3878,10 @@ public class ListView extends AbsListView { /** * Returns the set of checked items ids. The result is only valid if the * choice mode has not been set to {@link #CHOICE_MODE_NONE}. - * + * * @return A new array which contains the id of each checked item in the * list. - * + * * @deprecated Use {@link #getCheckedItemIds()} instead. */ @Deprecated diff --git a/core/java/android/widget/MenuItemHoverListener.java b/core/java/android/widget/MenuItemHoverListener.java index 13f0e6a0f43c..835e4cdb248c 100644 --- a/core/java/android/widget/MenuItemHoverListener.java +++ b/core/java/android/widget/MenuItemHoverListener.java @@ -1,10 +1,10 @@ package android.widget; -import com.android.internal.view.menu.MenuBuilder; - import android.annotation.NonNull; import android.view.MenuItem; +import com.android.internal.view.menu.MenuBuilder; + /** * An interface notified when a menu item is hovered. Useful for cases when hover should trigger * some behavior at a higher level, like managing the opening and closing of submenus. diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index 72b2e31a1d3a..662e64099fc8 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.CallSuper; import android.annotation.IntDef; import android.annotation.TestApi; @@ -32,12 +30,10 @@ import android.graphics.Paint.Align; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.text.Editable; import android.text.InputFilter; import android.text.InputType; import android.text.Spanned; import android.text.TextUtils; -import android.text.TextWatcher; import android.text.method.NumberKeyListener; import android.util.AttributeSet; import android.util.SparseArray; @@ -57,6 +53,10 @@ import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; +import com.android.internal.R; + +import libcore.icu.LocaleData; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; @@ -64,8 +64,6 @@ import java.util.Collections; import java.util.List; import java.util.Locale; -import libcore.icu.LocaleData; - /** * A widget that enables the user to select a number from a predefined range. * There are two flavors of this widget and which one is presented to the user diff --git a/core/java/android/widget/PopupMenu.java b/core/java/android/widget/PopupMenu.java index 027f8748dc17..eb27533c50ca 100644 --- a/core/java/android/widget/PopupMenu.java +++ b/core/java/android/widget/PopupMenu.java @@ -16,11 +16,6 @@ package android.widget; -import com.android.internal.R; -import com.android.internal.view.menu.MenuBuilder; -import com.android.internal.view.menu.MenuPopupHelper; -import com.android.internal.view.menu.ShowableListMenu; - import android.annotation.MenuRes; import android.content.Context; import android.view.Gravity; @@ -30,6 +25,11 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnTouchListener; +import com.android.internal.R; +import com.android.internal.view.menu.MenuBuilder; +import com.android.internal.view.menu.MenuPopupHelper; +import com.android.internal.view.menu.ShowableListMenu; + /** * A PopupMenu displays a {@link Menu} in a modal popup window anchored to a * {@link View}. The popup will appear below the anchor view if there is room, diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index 5e73a631d1fd..fc1520b84259 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -16,7 +16,11 @@ package android.widget; -import com.android.internal.R; +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; +import static android.view.WindowManager.LayoutParams + .PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH; import android.annotation.NonNull; import android.annotation.Nullable; @@ -50,12 +54,9 @@ import android.view.ViewTreeObserver.OnScrollChangedListener; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; -import java.lang.ref.WeakReference; +import com.android.internal.R; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH; -import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; -import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; +import java.lang.ref.WeakReference; /** * <p> diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index f9275f8f2e85..266ff7520d91 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -22,9 +22,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; -import android.content.res.Resources; import android.content.res.TypedArray; -import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.PorterDuff; import android.graphics.Rect; @@ -60,6 +58,7 @@ import android.view.animation.Interpolator; import android.view.animation.LinearInterpolator; import android.view.animation.Transformation; import android.widget.RemoteViews.RemoteView; + import com.android.internal.R; import java.util.ArrayList; diff --git a/core/java/android/widget/QuickContactBadge.java b/core/java/android/widget/QuickContactBadge.java index 8c15cde4764f..8f6b0d538e32 100644 --- a/core/java/android/widget/QuickContactBadge.java +++ b/core/java/android/widget/QuickContactBadge.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.content.AsyncQueryHandler; import android.content.ContentResolver; import android.content.Context; @@ -38,6 +36,8 @@ import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; +import com.android.internal.R; + /** * Widget used to show an image with the standard QuickContact badge * and on-click behavior. diff --git a/core/java/android/widget/RadialTimePickerView.java b/core/java/android/widget/RadialTimePickerView.java index 5a0e1f91d095..757a4ca04871 100644 --- a/core/java/android/widget/RadialTimePickerView.java +++ b/core/java/android/widget/RadialTimePickerView.java @@ -16,10 +16,6 @@ package android.widget; -import android.view.PointerIcon; -import com.android.internal.R; -import com.android.internal.widget.ExploreByTouchHelper; - import android.animation.ObjectAnimator; import android.annotation.IntDef; import android.content.Context; @@ -43,11 +39,15 @@ import android.util.StateSet; import android.util.TypedValue; import android.view.HapticFeedbackConstants; import android.view.MotionEvent; +import android.view.PointerIcon; import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; +import com.android.internal.R; +import com.android.internal.widget.ExploreByTouchHelper; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Calendar; diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java index 065feb8b334e..54b57631366f 100644 --- a/core/java/android/widget/RadioGroup.java +++ b/core/java/android/widget/RadioGroup.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.IdRes; import android.content.Context; import android.content.res.TypedArray; @@ -25,6 +23,8 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; +import com.android.internal.R; + /** * <p>This class is used to create a multiple-exclusion scope for a set of radio @@ -39,14 +39,14 @@ import android.view.ViewGroup; * in the XML layout file.</p> * * <p><strong>XML Attributes</strong></p> - * <p>See {@link android.R.styleable#RadioGroup RadioGroup Attributes}, + * <p>See {@link android.R.styleable#RadioGroup RadioGroup Attributes}, * {@link android.R.styleable#LinearLayout LinearLayout Attributes}, * {@link android.R.styleable#ViewGroup ViewGroup Attributes}, * {@link android.R.styleable#View View Attributes}</p> * <p>Also see * {@link android.widget.LinearLayout.LayoutParams LinearLayout.LayoutParams} * for layout attributes.</p> - * + * * @see RadioButton * */ @@ -310,7 +310,7 @@ public class RadioGroup extends LinearLayout { } else { width = WRAP_CONTENT; } - + if (a.hasValue(heightAttr)) { height = a.getLayoutDimension(heightAttr, "layout_height"); } else { diff --git a/core/java/android/widget/RatingBar.java b/core/java/android/widget/RatingBar.java index 62dd90fddcd0..3b7fe86a5fa1 100644 --- a/core/java/android/widget/RatingBar.java +++ b/core/java/android/widget/RatingBar.java @@ -22,6 +22,7 @@ import android.graphics.drawable.shapes.RectShape; import android.graphics.drawable.shapes.Shape; import android.util.AttributeSet; import android.view.accessibility.AccessibilityNodeInfo; + import com.android.internal.R; /** diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index a189d3c0cc91..b424101d0470 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -16,20 +16,14 @@ package android.widget; -import android.annotation.NonNull; -import android.util.ArrayMap; -import com.android.internal.R; - -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.SortedSet; -import java.util.TreeSet; +import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; +import android.annotation.NonNull; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; import android.os.Build; +import android.util.ArrayMap; import android.util.AttributeSet; import android.util.Pools.SynchronizedPool; import android.util.SparseArray; @@ -41,7 +35,13 @@ import android.view.ViewHierarchyEncoder; import android.view.accessibility.AccessibilityEvent; import android.widget.RemoteViews.RemoteView; -import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; +import com.android.internal.R; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.SortedSet; +import java.util.TreeSet; /** * A Layout where the positions of the children can be described in relation to each other or to the @@ -209,7 +209,7 @@ public class RelativeLayout extends ViewGroup { private int mIgnoreGravity; private SortedSet<View> mTopToBottomLeftToRightSet = null; - + private boolean mDirtyHierarchy; private View[] mSortedHorizontalChildren; private View[] mSortedVerticalChildren; diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 2a6e01f91b21..6543d0cf8bdd 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -59,11 +59,12 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.AdapterView.OnItemClickListener; -import libcore.util.Objects; import com.android.internal.R; import com.android.internal.util.Preconditions; +import libcore.util.Objects; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/core/java/android/widget/RemoteViewsAdapter.java b/core/java/android/widget/RemoteViewsAdapter.java index 10abbab6aacd..e0f94fd207d3 100644 --- a/core/java/android/widget/RemoteViewsAdapter.java +++ b/core/java/android/widget/RemoteViewsAdapter.java @@ -16,13 +16,6 @@ package android.widget; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; - import android.Manifest; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetManager; @@ -48,6 +41,11 @@ import android.widget.RemoteViews.OnClickHandler; import com.android.internal.widget.IRemoteViewsAdapterConnection; import com.android.internal.widget.IRemoteViewsFactory; +import java.lang.ref.WeakReference; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; + /** * An adapter to a RemoteViewsService which fetches and caches RemoteViews * to be later inflated as child views. diff --git a/core/java/android/widget/RemoteViewsService.java b/core/java/android/widget/RemoteViewsService.java index 07bd9188dca4..2827f634b389 100644 --- a/core/java/android/widget/RemoteViewsService.java +++ b/core/java/android/widget/RemoteViewsService.java @@ -16,14 +16,14 @@ package android.widget; -import java.util.HashMap; - import android.app.Service; import android.content.Intent; import android.os.IBinder; import com.android.internal.widget.IRemoteViewsFactory; +import java.util.HashMap; + /** * The service to be connected to for a remote adapter to request RemoteViews. Users should * extend the RemoteViewsService to provide the appropriate RemoteViewsFactory's used to @@ -46,7 +46,7 @@ public abstract class RemoteViewsService extends Service { * An interface for an adapter between a remote collection view (ListView, GridView, etc) and * the underlying data for that view. The implementor is responsible for making a RemoteView * for each item in the data set. This interface is a thin wrapper around {@link Adapter}. - * + * * @see android.widget.Adapter * @see android.appwidget.AppWidgetManager */ diff --git a/core/java/android/widget/ResourceCursorAdapter.java b/core/java/android/widget/ResourceCursorAdapter.java index 100f9192dd39..9732bb105c34 100644 --- a/core/java/android/widget/ResourceCursorAdapter.java +++ b/core/java/android/widget/ResourceCursorAdapter.java @@ -20,9 +20,9 @@ import android.content.Context; import android.content.res.Resources; import android.database.Cursor; import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.LayoutInflater; /** @@ -148,7 +148,7 @@ public abstract class ResourceCursorAdapter extends CursorAdapter { public void setViewResource(int layout) { mLayout = layout; } - + /** * <p>Sets the layout resource of the drop down views.</p> * diff --git a/core/java/android/widget/ResourceCursorTreeAdapter.java b/core/java/android/widget/ResourceCursorTreeAdapter.java index ddce515d825a..0894dba136c9 100644 --- a/core/java/android/widget/ResourceCursorTreeAdapter.java +++ b/core/java/android/widget/ResourceCursorTreeAdapter.java @@ -18,9 +18,9 @@ package android.widget; import android.content.Context; import android.database.Cursor; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.LayoutInflater; /** * A fairly simple ExpandableListAdapter that creates views defined in an XML @@ -32,10 +32,10 @@ public abstract class ResourceCursorTreeAdapter extends CursorTreeAdapter { private int mChildLayout; private int mLastChildLayout; private LayoutInflater mInflater; - + /** * Constructor. - * + * * @param context The context where the ListView associated with this * SimpleListItemFactory is running * @param cursor The database cursor @@ -51,18 +51,18 @@ public abstract class ResourceCursorTreeAdapter extends CursorTreeAdapter { public ResourceCursorTreeAdapter(Context context, Cursor cursor, int collapsedGroupLayout, int expandedGroupLayout, int childLayout, int lastChildLayout) { super(cursor, context); - + mCollapsedGroupLayout = collapsedGroupLayout; mExpandedGroupLayout = expandedGroupLayout; mChildLayout = childLayout; mLastChildLayout = lastChildLayout; - + mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } /** * Constructor. - * + * * @param context The context where the ListView associated with this * SimpleListItemFactory is running * @param cursor The database cursor @@ -80,7 +80,7 @@ public abstract class ResourceCursorTreeAdapter extends CursorTreeAdapter { /** * Constructor. - * + * * @param context The context where the ListView associated with this * SimpleListItemFactory is running * @param cursor The database cursor @@ -93,7 +93,7 @@ public abstract class ResourceCursorTreeAdapter extends CursorTreeAdapter { int childLayout) { this(context, cursor, groupLayout, groupLayout, childLayout, childLayout); } - + @Override public View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent) { diff --git a/core/java/android/widget/ScrollBarDrawable.java b/core/java/android/widget/ScrollBarDrawable.java index 11eab2adad30..2ae38c9aa3fb 100644 --- a/core/java/android/widget/ScrollBarDrawable.java +++ b/core/java/android/widget/ScrollBarDrawable.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.widget.ScrollBarUtils; - import android.annotation.NonNull; import android.graphics.Canvas; import android.graphics.ColorFilter; @@ -25,6 +23,8 @@ import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import com.android.internal.widget.ScrollBarUtils; + /** * This is only used by View for displaying its scroll bars. It should probably * be moved in to the view package since it is used in that lower-level layer. diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index e696ff7229e8..d8f337926073 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -17,18 +17,16 @@ package android.widget; import android.annotation.NonNull; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Build.VERSION_CODES; -import android.os.Parcel; -import android.os.Parcelable; -import com.android.internal.R; - import android.content.Context; +import android.content.res.Configuration; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Rect; +import android.os.Build; +import android.os.Build.VERSION_CODES; import android.os.Bundle; +import android.os.Parcel; +import android.os.Parcelable; import android.os.StrictMode; import android.util.AttributeSet; import android.util.Log; @@ -47,6 +45,8 @@ import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.AnimationUtils; +import com.android.internal.R; + import java.util.List; /** diff --git a/core/java/android/widget/SimpleAdapter.java b/core/java/android/widget/SimpleAdapter.java index 3bf94850deef..91901178e81e 100644 --- a/core/java/android/widget/SimpleAdapter.java +++ b/core/java/android/widget/SimpleAdapter.java @@ -20,11 +20,11 @@ import android.annotation.IdRes; import android.annotation.LayoutRes; import android.content.Context; import android.content.res.Resources; +import android.net.Uri; import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.LayoutInflater; -import android.net.Uri; import java.util.ArrayList; import java.util.List; @@ -40,7 +40,7 @@ import java.util.Map; * Binding data to views occurs in two phases. First, if a * {@link android.widget.SimpleAdapter.ViewBinder} is available, * {@link ViewBinder#setViewValue(android.view.View, Object, String)} - * is invoked. If the returned value is true, binding has occurred. + * is invoked. If the returned value is true, binding has occurred. * If the returned value is false, the following views are then tried in order: * <ul> * <li> A view that implements Checkable (e.g. CheckBox). The expected bind value is a boolean. @@ -223,7 +223,7 @@ public class SimpleAdapter extends BaseAdapter implements Filterable, ThemedSpin setViewText((TextView) v, text); } else if (v instanceof ImageView) { if (data instanceof Integer) { - setViewImage((ImageView) v, (Integer) data); + setViewImage((ImageView) v, (Integer) data); } else { setViewImage((ImageView) v, text); } @@ -291,7 +291,7 @@ public class SimpleAdapter extends BaseAdapter implements Filterable, ThemedSpin * @param v ImageView to receive an image * @param value the value retrieved from the data set * - * @see #setViewImage(ImageView, int) + * @see #setViewImage(ImageView, int) */ public void setViewImage(ImageView v, String value) { try { @@ -381,18 +381,18 @@ public class SimpleAdapter extends BaseAdapter implements Filterable, ThemedSpin for (int i = 0; i < count; i++) { Map<String, ?> h = unfilteredValues.get(i); if (h != null) { - + int len = mTo.length; for (int j=0; j<len; j++) { String str = (String)h.get(mFrom[j]); - + String[] words = str.split(" "); int wordCount = words.length; - + for (int k = 0; k < wordCount; k++) { String word = words[k]; - + if (word.toLowerCase().startsWith(prefixString)) { newValues.add(h); break; diff --git a/core/java/android/widget/SimpleExpandableListAdapter.java b/core/java/android/widget/SimpleExpandableListAdapter.java index 015c169f74b5..597502b707e0 100644 --- a/core/java/android/widget/SimpleExpandableListAdapter.java +++ b/core/java/android/widget/SimpleExpandableListAdapter.java @@ -17,9 +17,9 @@ package android.widget; import android.content.Context; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.LayoutInflater; import java.util.List; import java.util.Map; @@ -42,18 +42,18 @@ public class SimpleExpandableListAdapter extends BaseExpandableListAdapter { private int mCollapsedGroupLayout; private String[] mGroupFrom; private int[] mGroupTo; - + private List<? extends List<? extends Map<String, ?>>> mChildData; private int mChildLayout; private int mLastChildLayout; private String[] mChildFrom; private int[] mChildTo; - + private LayoutInflater mInflater; - + /** * Constructor - * + * * @param context The context where the {@link ExpandableListView} * associated with this {@link SimpleExpandableListAdapter} is * running @@ -98,7 +98,7 @@ public class SimpleExpandableListAdapter extends BaseExpandableListAdapter { /** * Constructor - * + * * @param context The context where the {@link ExpandableListView} * associated with this {@link SimpleExpandableListAdapter} is * running @@ -147,7 +147,7 @@ public class SimpleExpandableListAdapter extends BaseExpandableListAdapter { /** * Constructor - * + * * @param context The context where the {@link ExpandableListView} * associated with this {@link SimpleExpandableListAdapter} is * running @@ -200,16 +200,16 @@ public class SimpleExpandableListAdapter extends BaseExpandableListAdapter { mCollapsedGroupLayout = collapsedGroupLayout; mGroupFrom = groupFrom; mGroupTo = groupTo; - + mChildData = childData; mChildLayout = childLayout; mLastChildLayout = lastChildLayout; mChildFrom = childFrom; mChildTo = childTo; - + mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } - + public Object getChild(int groupPosition, int childPosition) { return mChildData.get(groupPosition).get(childPosition); } @@ -239,7 +239,7 @@ public class SimpleExpandableListAdapter extends BaseExpandableListAdapter { public View newChildView(boolean isLastChild, ViewGroup parent) { return mInflater.inflate((isLastChild) ? mLastChildLayout : mChildLayout, parent, false); } - + private void bindView(View view, Map<String, ?> data, String[] from, int[] to) { int len = to.length; diff --git a/core/java/android/widget/SimpleMonthView.java b/core/java/android/widget/SimpleMonthView.java index 8c4378222a77..855d1d288a65 100644 --- a/core/java/android/widget/SimpleMonthView.java +++ b/core/java/android/widget/SimpleMonthView.java @@ -16,10 +16,6 @@ package android.widget; -import android.view.PointerIcon; -import com.android.internal.R; -import com.android.internal.widget.ExploreByTouchHelper; - import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; @@ -43,17 +39,21 @@ import android.util.MathUtils; import android.util.StateSet; import android.view.KeyEvent; import android.view.MotionEvent; +import android.view.PointerIcon; import android.view.View; import android.view.ViewParent; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; -import java.text.NumberFormat; -import java.util.Locale; +import com.android.internal.R; +import com.android.internal.widget.ExploreByTouchHelper; import libcore.icu.LocaleData; +import java.text.NumberFormat; +import java.util.Locale; + /** * A calendar-like view displaying a specified month and the appropriate selectable day numbers * within the specified month. diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index dc5e5a2964a4..28cc693f3b31 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -16,13 +16,9 @@ package android.widget; -import android.annotation.TestApi; -import android.view.PointerIcon; -import com.android.internal.R; -import com.android.internal.view.menu.ShowableListMenu; - import android.annotation.DrawableRes; import android.annotation.Nullable; +import android.annotation.TestApi; import android.annotation.Widget; import android.app.AlertDialog; import android.content.Context; @@ -42,6 +38,7 @@ import android.util.Log; import android.view.ContextThemeWrapper; import android.view.Gravity; import android.view.MotionEvent; +import android.view.PointerIcon; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; @@ -49,6 +46,9 @@ import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.PopupWindow.OnDismissListener; +import com.android.internal.R; +import com.android.internal.view.menu.ShowableListMenu; + /** * A view that displays one child at a time and lets the user pick among them. * The items in the Spinner come from the {@link Adapter} associated with @@ -123,7 +123,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { * access the current theme, resources, etc. * @param mode Constant describing how the user will select choices from * the spinner. - * + * * @see #MODE_DIALOG * @see #MODE_DROPDOWN */ @@ -563,7 +563,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - + if (mPopup != null && mPopup.isShowing()) { mPopup.dismiss(); } @@ -772,7 +772,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { @Override public boolean performClick() { boolean handled = super.performClick(); - + if (!handled) { handled = true; @@ -1011,7 +1011,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { /** * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. - * Otherwise, return true. + * Otherwise, return true. */ public boolean areAllItemsEnabled() { final ListAdapter adapter = mListAdapter; @@ -1042,19 +1042,19 @@ public class Spinner extends AbsSpinner implements OnClickListener { public int getViewTypeCount() { return 1; } - + public boolean isEmpty() { return getCount() == 0; } } - + /** * Implements some sort of popup selection interface for selecting a spinner option. * Allows for different spinner modes. */ private interface SpinnerPopup { public void setAdapter(ListAdapter adapter); - + /** * Show the popup */ @@ -1064,12 +1064,12 @@ public class Spinner extends AbsSpinner implements OnClickListener { * Dismiss the popup */ public void dismiss(); - + /** * @return true if the popup is showing, false otherwise. */ public boolean isShowing(); - + /** * Set hint text to be displayed to the user. This should provide * a description of the choice being made. @@ -1129,7 +1129,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { listView.setTextAlignment(textAlignment); mPopup.show(); } - + public void onClick(DialogInterface dialog, int which) { setSelection(which); if (mOnItemClickListener != null) { @@ -1168,7 +1168,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { return 0; } } - + private class DropdownPopup extends ListPopupWindow implements SpinnerPopup { private CharSequence mHintText; private ListAdapter mAdapter; @@ -1190,7 +1190,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { } }); } - + @Override public void setAdapter(ListAdapter adapter) { super.setAdapter(adapter); @@ -1200,7 +1200,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { public CharSequence getHintText() { return mHintText; } - + public void setPromptText(CharSequence hintText) { // Hint text is ignored for dropdowns, but maintain it here. mHintText = hintText; diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index 2bd31438976b..0e99c02cc6aa 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -15,8 +15,6 @@ package android.widget; -import java.lang.ref.WeakReference; - import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.content.Context; @@ -45,6 +43,8 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.LinearInterpolator; import android.widget.RemoteViews.RemoteView; +import java.lang.ref.WeakReference; + @RemoteView /** * A view that displays its children in a stack and allows users to discretely swipe @@ -670,12 +670,12 @@ public class StackView extends AdapterViewAnimator { activeIndex = (swipeGestureType == GESTURE_SLIDE_DOWN) ? 1 : 0; } - boolean endOfStack = mLoopViews && adapterCount == 1 && - ((mStackMode == ITEMS_SLIDE_UP && swipeGestureType == GESTURE_SLIDE_UP) || - (mStackMode == ITEMS_SLIDE_DOWN && swipeGestureType == GESTURE_SLIDE_DOWN)); - boolean beginningOfStack = mLoopViews && adapterCount == 1 && - ((mStackMode == ITEMS_SLIDE_DOWN && swipeGestureType == GESTURE_SLIDE_UP) || - (mStackMode == ITEMS_SLIDE_UP && swipeGestureType == GESTURE_SLIDE_DOWN)); + boolean endOfStack = mLoopViews && adapterCount == 1 + && ((mStackMode == ITEMS_SLIDE_UP && swipeGestureType == GESTURE_SLIDE_UP) + || (mStackMode == ITEMS_SLIDE_DOWN && swipeGestureType == GESTURE_SLIDE_DOWN)); + boolean beginningOfStack = mLoopViews && adapterCount == 1 + && ((mStackMode == ITEMS_SLIDE_DOWN && swipeGestureType == GESTURE_SLIDE_UP) + || (mStackMode == ITEMS_SLIDE_UP && swipeGestureType == GESTURE_SLIDE_DOWN)); int stackMode; if (mLoopViews && !beginningOfStack && !endOfStack) { diff --git a/core/java/android/widget/SuggestionsAdapter.java b/core/java/android/widget/SuggestionsAdapter.java index aad0625e71ca..f833d1b4a9d6 100644 --- a/core/java/android/widget/SuggestionsAdapter.java +++ b/core/java/android/widget/SuggestionsAdapter.java @@ -21,8 +21,8 @@ import android.app.SearchManager; import android.app.SearchableInfo; import android.content.ComponentName; import android.content.ContentResolver; -import android.content.Context; import android.content.ContentResolver.OpenResourceIdResult; +import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; @@ -39,8 +39,8 @@ import android.text.style.TextAppearanceSpan; import android.util.Log; import android.util.TypedValue; import android.view.View; -import android.view.ViewGroup; import android.view.View.OnClickListener; +import android.view.ViewGroup; import com.android.internal.R; @@ -111,7 +111,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene mProviderContext = mSearchable.getProviderContext(mContext, activityContext); mOutsideDrawablesCache = outsideDrawablesCache; - + // mStartSpinnerRunnable = new Runnable() { // public void run() { // // mSearchView.setWorking(true); // TODO: diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index d51c5be640ae..fcc1667d8043 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -30,8 +30,8 @@ import android.graphics.Insets; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.Rect; -import android.graphics.Typeface; import android.graphics.Region.Op; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.text.Layout; import android.text.StaticLayout; @@ -46,8 +46,8 @@ import android.view.Gravity; import android.view.MotionEvent; import android.view.SoundEffectConstants; import android.view.VelocityTracker; -import android.view.ViewStructure; import android.view.ViewConfiguration; +import android.view.ViewStructure; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java index 583f037813f3..32418cdb8240 100644 --- a/core/java/android/widget/TabHost.java +++ b/core/java/android/widget/TabHost.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.NonNull; import android.annotation.Nullable; import android.app.LocalActivityManager; @@ -35,6 +33,9 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.Window; + +import com.android.internal.R; + import java.util.ArrayList; import java.util.List; diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java index 1f0cb7cebe56..05f7c0a1ee08 100644 --- a/core/java/android/widget/TabWidget.java +++ b/core/java/android/widget/TabWidget.java @@ -16,10 +16,6 @@ package android.widget; -import android.view.MotionEvent; -import android.view.PointerIcon; -import com.android.internal.R; - import android.annotation.DrawableRes; import android.annotation.Nullable; import android.content.Context; @@ -29,11 +25,15 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.PointerIcon; import android.view.View; import android.view.View.OnFocusChangeListener; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; +import com.android.internal.R; + /** * * Displays a list of tab labels representing each page in the parent's tab diff --git a/core/java/android/widget/TableLayout.java b/core/java/android/widget/TableLayout.java index eed3c2d2c8e1..8bb4d16fe7df 100644 --- a/core/java/android/widget/TableLayout.java +++ b/core/java/android/widget/TableLayout.java @@ -16,14 +16,15 @@ package android.widget; -import com.android.internal.R; - import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.util.SparseBooleanArray; import android.view.View; import android.view.ViewGroup; + +import com.android.internal.R; + import java.util.regex.Pattern; /** diff --git a/core/java/android/widget/TextClock.java b/core/java/android/widget/TextClock.java index 5003c610241a..a6a9db44c420 100644 --- a/core/java/android/widget/TextClock.java +++ b/core/java/android/widget/TextClock.java @@ -16,6 +16,9 @@ package android.widget; +import static android.view.ViewDebug.ExportedProperty; +import static android.widget.RemoteViews.RemoteView; + import android.annotation.NonNull; import android.app.ActivityManager; import android.content.BroadcastReceiver; @@ -37,13 +40,10 @@ import android.view.ViewHierarchyEncoder; import com.android.internal.R; -import java.util.Calendar; -import java.util.TimeZone; - import libcore.icu.LocaleData; -import static android.view.ViewDebug.ExportedProperty; -import static android.widget.RemoteViews.*; +import java.util.Calendar; +import java.util.TimeZone; /** * <p><code>TextClock</code> can display the current date and/or time as diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java index 6a76c5bb2b76..e6cd7987d59a 100644 --- a/core/java/android/widget/TimePicker.java +++ b/core/java/android/widget/TimePicker.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; @@ -32,12 +30,14 @@ import android.util.MathUtils; import android.view.View; import android.view.accessibility.AccessibilityEvent; +import com.android.internal.R; + +import libcore.icu.LocaleData; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Locale; -import libcore.icu.LocaleData; - /** * A widget for selecting the time of day, in either 24-hour or AM/PM mode. * <p> diff --git a/core/java/android/widget/TimePickerSpinnerDelegate.java b/core/java/android/widget/TimePickerSpinnerDelegate.java index 26e1564aff6b..6a68f60b2c7a 100644 --- a/core/java/android/widget/TimePickerSpinnerDelegate.java +++ b/core/java/android/widget/TimePickerSpinnerDelegate.java @@ -16,6 +16,9 @@ package android.widget; +import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO; +import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_YES; + import android.annotation.TestApi; import android.content.Context; import android.content.res.TypedArray; @@ -29,14 +32,12 @@ import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; -import com.android.internal.R; -import java.util.Calendar; +import com.android.internal.R; import libcore.icu.LocaleData; -import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO; -import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_YES; +import java.util.Calendar; /** * A delegate implementing the basic spinner-based TimePicker. diff --git a/core/java/android/widget/TwoLineListItem.java b/core/java/android/widget/TwoLineListItem.java index 69ff488b5b47..0445ebd50926 100644 --- a/core/java/android/widget/TwoLineListItem.java +++ b/core/java/android/widget/TwoLineListItem.java @@ -20,22 +20,21 @@ import android.annotation.Widget; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; -import android.widget.RelativeLayout; /** - * <p>A view group with two children, intended for use in ListViews. This item has two - * {@link android.widget.TextView TextViews} elements (or subclasses) with the ID values + * <p>A view group with two children, intended for use in ListViews. This item has two + * {@link android.widget.TextView TextViews} elements (or subclasses) with the ID values * {@link android.R.id#text1 text1} - * and {@link android.R.id#text2 text2}. There is an optional third View element with the - * ID {@link android.R.id#selectedIcon selectedIcon}, which can be any View subclass + * and {@link android.R.id#text2 text2}. There is an optional third View element with the + * ID {@link android.R.id#selectedIcon selectedIcon}, which can be any View subclass * (though it is typically a graphic View, such as {@link android.widget.ImageView ImageView}) - * that can be displayed when a TwoLineListItem has focus. Android supplies a - * {@link android.R.layout#two_line_list_item standard layout resource for TwoLineListView} + * that can be displayed when a TwoLineListItem has focus. Android supplies a + * {@link android.R.layout#two_line_list_item standard layout resource for TwoLineListView} * (which does not include a selected item icon), but you can design your own custom XML * layout for this object. - * + * * @attr ref android.R.styleable#TwoLineListItem_mode - * + * * @deprecated This class can be implemented easily by apps using a {@link RelativeLayout} * or a {@link LinearLayout}. */ @@ -51,7 +50,7 @@ public class TwoLineListItem extends RelativeLayout { } public TwoLineListItem(Context context, AttributeSet attrs) { - this(context, attrs, 0); + this(context, attrs, 0); } public TwoLineListItem(Context context, AttributeSet attrs, int defStyleAttr) { @@ -70,11 +69,11 @@ public class TwoLineListItem extends RelativeLayout { @Override protected void onFinishInflate() { super.onFinishInflate(); - + mText1 = (TextView) findViewById(com.android.internal.R.id.text1); mText2 = (TextView) findViewById(com.android.internal.R.id.text2); } - + /** * Returns a handle to the item with ID text1. * @return A handle to the item with ID text1. @@ -82,7 +81,7 @@ public class TwoLineListItem extends RelativeLayout { public TextView getText1() { return mText1; } - + /** * Returns a handle to the item with ID text2. * @return A handle to the item with ID text2. diff --git a/core/java/android/widget/ViewFlipper.java b/core/java/android/widget/ViewFlipper.java index 65af7aa28a6b..e769d71b66eb 100644 --- a/core/java/android/widget/ViewFlipper.java +++ b/core/java/android/widget/ViewFlipper.java @@ -21,7 +21,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.TypedArray; -import android.os.*; +import android.os.Message; import android.util.AttributeSet; import android.util.Log; import android.widget.RemoteViews.RemoteView; diff --git a/core/java/android/widget/YearPickerView.java b/core/java/android/widget/YearPickerView.java index a3f5a67baca1..824fec85de16 100644 --- a/core/java/android/widget/YearPickerView.java +++ b/core/java/android/widget/YearPickerView.java @@ -16,8 +16,6 @@ package android.widget; -import com.android.internal.R; - import android.content.Context; import android.content.res.Resources; import android.icu.util.Calendar; @@ -27,6 +25,8 @@ import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; +import com.android.internal.R; + /** * Displays a selectable list of years. */ diff --git a/core/java/android/widget/ZoomButtonsController.java b/core/java/android/widget/ZoomButtonsController.java index fb912a4e1882..69b799716f02 100644 --- a/core/java/android/widget/ZoomButtonsController.java +++ b/core/java/android/widget/ZoomButtonsController.java @@ -30,11 +30,11 @@ import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewRootImpl; import android.view.WindowManager; -import android.view.View.OnClickListener; import android.view.WindowManager.LayoutParams; /* diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index 433331072e03..9ed15881355b 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -1188,6 +1188,13 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle, return JNI_TRUE; } +static jlong Bitmap_refPixelRef(JNIEnv* env, jobject, jlong bitmapHandle) { + LocalScopedBitmap bitmap(bitmapHandle); + SkPixelRef* pixelRef = bitmap->pixelRef(); + SkSafeRef(pixelRef); + return reinterpret_cast<jlong>(pixelRef); +} + static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapPtr) { LocalScopedBitmap bitmapHandle(bitmapPtr); if (!bitmapHandle.valid()) return; @@ -1257,6 +1264,7 @@ static const JNINativeMethod gBitmapMethods[] = { { "nativeCopyPixelsFromBuffer", "(JLjava/nio/Buffer;)V", (void*)Bitmap_copyPixelsFromBuffer }, { "nativeSameAs", "(JJ)Z", (void*)Bitmap_sameAs }, + { "nativeRefPixelRef", "(J)J", (void*)Bitmap_refPixelRef }, { "nativePrepareToDraw", "(J)V", (void*)Bitmap_prepareToDraw }, { "nativeGetAllocationByteCount", "(J)I", (void*)Bitmap_getAllocationByteCount }, }; diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index f7082920a018..7ce750d6e000 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -1654,6 +1654,16 @@ public final class Bitmap implements Parcelable { nativePrepareToDraw(mNativePtr); } + /** + * Refs the underlying SkPixelRef and returns a pointer to it. + * + * @hide + * */ + public final long refSkPixelRef() { + checkRecycled("Can't refSkPixelRef on a recycled bitmap!"); + return nativeRefPixelRef(mNativePtr); + } + //////////// native methods private static native Bitmap nativeCreate(int[] colors, int offset, @@ -1710,6 +1720,7 @@ public final class Bitmap implements Parcelable { private static native boolean nativeHasMipMap(long nativeBitmap); private static native void nativeSetHasMipMap(long nativeBitmap, boolean hasMipMap); private static native boolean nativeSameAs(long nativeBitmap0, long nativeBitmap1); + private static native long nativeRefPixelRef(long nativeBitmap); private static native void nativePrepareToDraw(long nativeBitmap); private static native int nativeGetAllocationByteCount(long nativeBitmap); } diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index 796cb3633626..371bc9a25735 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -35,6 +35,9 @@ #include <utils/threads.h> #include <utils/Timers.h> #include <utils/Trace.h> +#ifndef _WIN32 +#include <sys/file.h> +#endif #include <assert.h> #include <dirent.h> @@ -647,6 +650,12 @@ void AssetManager::addSystemOverlays(const char* pathOverlaysList, return; } +#ifndef _WIN32 + if (TEMP_FAILURE_RETRY(flock(fileno(fin), LOCK_SH)) != 0) { + fclose(fin); + return; + } +#endif char buf[1024]; while (fgets(buf, sizeof(buf), fin)) { // format of each line: @@ -677,6 +686,10 @@ void AssetManager::addSystemOverlays(const char* pathOverlaysList, const_cast<AssetManager*>(this)->mZipSet.addOverlay(targetPackagePath, oap); } } + +#ifndef _WIN32 + TEMP_FAILURE_RETRY(flock(fileno(fin), LOCK_UN)); +#endif fclose(fin); } diff --git a/libs/hwui/Extensions.cpp b/libs/hwui/Extensions.cpp index 4dc7536d60bc..1d675791b851 100644 --- a/libs/hwui/Extensions.cpp +++ b/libs/hwui/Extensions.cpp @@ -45,13 +45,18 @@ Extensions::Extensions() { mHas1BitStencil = extensions.has("GL_OES_stencil1"); mHas4BitStencil = extensions.has("GL_OES_stencil4"); mHasUnpackSubImage = extensions.has("GL_EXT_unpack_subimage"); - mHasSRGB = extensions.has("GL_EXT_sRGB"); - mHasSRGBWriteControl = extensions.has("GL_EXT_sRGB_write_control"); - // If linear blending is enabled, the device must have ES3.0 and GL_EXT_sRGB_write_control #ifdef ANDROID_ENABLE_LINEAR_BLENDING - assert(mVersionMajor >= 3 || mHasSRGB); - assert(mHasSRGBWriteControl); + mHasSRGB = mVersionMajor >= 3 || extensions.has("GL_EXT_sRGB"); + mHasSRGBWriteControl = extensions.has("GL_EXT_sRGB_write_control"); + + // If linear blending is enabled, the device must have (ES3.0 or EXT_sRGB) + // and EXT_sRGB_write_control + LOG_ALWAYS_FATAL_IF(!mHasSRGB, "Linear blending requires ES 3.0 or EXT_sRGB"); + LOG_ALWAYS_FATAL_IF(!mHasSRGBWriteControl, "Linear blending requires EXT_sRGB_write_control"); +#else + mHasSRGB = false; + mHasSRGBWriteControl = false; #endif const char* version = (const char*) glGetString(GL_VERSION); diff --git a/libs/hwui/Extensions.h b/libs/hwui/Extensions.h index cc73c2317720..2c38507bd79a 100644 --- a/libs/hwui/Extensions.h +++ b/libs/hwui/Extensions.h @@ -43,7 +43,7 @@ public: inline bool hasPixelBufferObjects() const { return mVersionMajor >= 3; } inline bool hasOcclusionQueries() const { return mVersionMajor >= 3; } inline bool hasFloatTextures() const { return mVersionMajor >= 3; } - inline bool hasSRGB() const { return mVersionMajor >= 3 || mHasSRGB; } + inline bool hasSRGB() const { return mHasSRGB; } inline bool hasSRGBWriteControl() const { return hasSRGB() && mHasSRGBWriteControl; } inline int getMajorGlVersion() const { return mVersionMajor; } diff --git a/libs/hwui/FloatColor.h b/libs/hwui/FloatColor.h index 6d19b7ccdd79..9df73387c36a 100644 --- a/libs/hwui/FloatColor.h +++ b/libs/hwui/FloatColor.h @@ -28,8 +28,20 @@ namespace uirenderer { struct FloatColor { // "color" is a gamma-encoded sRGB color // After calling this method, the color is stored as a pre-multiplied linear color + // if linear blending is enabled. Otherwise, the color is stored as a pre-multiplied + // gamma-encoded sRGB color void set(uint32_t color) { a = ((color >> 24) & 0xff) / 255.0f; + r = a * EOCF(((color >> 16) & 0xff) / 255.0f); + g = a * EOCF(((color >> 8) & 0xff) / 255.0f); + b = a * EOCF(((color ) & 0xff) / 255.0f); + } + + // "color" is a gamma-encoded sRGB color + // After calling this method, the color is stored as a pre-multiplied linear color + // if linear blending is enabled. + void setSRGB(uint32_t color) { + a = ((color >> 24) & 0xff) / 255.0f; r = a * EOCF_sRGB(((color >> 16) & 0xff) / 255.0f); g = a * EOCF_sRGB(((color >> 8) & 0xff) / 255.0f); b = a * EOCF_sRGB(((color ) & 0xff) / 255.0f); diff --git a/libs/hwui/GlopBuilder.cpp b/libs/hwui/GlopBuilder.cpp index ff88d020030c..65922f68bd09 100644 --- a/libs/hwui/GlopBuilder.cpp +++ b/libs/hwui/GlopBuilder.cpp @@ -289,10 +289,10 @@ void GlopBuilder::setFill(int color, float alphaScale, // Skia uses the range [0..255] for the addition vector, but we need // the [0..1] range to apply the vector in GLSL float* colorVector = mOutGlop->fill.filter.matrix.vector; - colorVector[0] = EOCF_sRGB(srcColorMatrix[4] / 255.0f); - colorVector[1] = EOCF_sRGB(srcColorMatrix[9] / 255.0f); - colorVector[2] = EOCF_sRGB(srcColorMatrix[14] / 255.0f); - colorVector[3] = EOCF_sRGB(srcColorMatrix[19] / 255.0f); + colorVector[0] = EOCF(srcColorMatrix[4] / 255.0f); + colorVector[1] = EOCF(srcColorMatrix[9] / 255.0f); + colorVector[2] = EOCF(srcColorMatrix[14] / 255.0f); + colorVector[3] = srcColorMatrix[19] / 255.0f; // alpha is linear } else { LOG_ALWAYS_FATAL("unsupported ColorFilter"); } diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp index 8573ab078aaf..cd3ccf9b8fc7 100644 --- a/libs/hwui/GradientCache.cpp +++ b/libs/hwui/GradientCache.cpp @@ -185,22 +185,28 @@ size_t GradientCache::sourceBytesPerPixel() const { return 4 * (mUseFloatTexture ? sizeof(float) : sizeof(uint8_t)); } -void GradientCache::mixBytes(FloatColor& start, FloatColor& end, float amount, - uint8_t*& dst) const { +void GradientCache::mixBytes(const FloatColor& start, const FloatColor& end, + float amount, uint8_t*& dst) const { float oppAmount = 1.0f - amount; - *dst++ = uint8_t(OECF_sRGB((start.r * oppAmount + end.r * amount) * 255.0f)); - *dst++ = uint8_t(OECF_sRGB((start.g * oppAmount + end.g * amount) * 255.0f)); - *dst++ = uint8_t(OECF_sRGB((start.b * oppAmount + end.b * amount) * 255.0f)); - *dst++ = uint8_t( (start.a * oppAmount + end.a * amount) * 255.0f); + *dst++ = uint8_t(OECF_sRGB(start.r * oppAmount + end.r * amount) * 255.0f); + *dst++ = uint8_t(OECF_sRGB(start.g * oppAmount + end.g * amount) * 255.0f); + *dst++ = uint8_t(OECF_sRGB(start.b * oppAmount + end.b * amount) * 255.0f); + *dst++ = uint8_t( (start.a * oppAmount + end.a * amount) * 255.0f); } -void GradientCache::mixFloats(FloatColor& start, FloatColor& end, float amount, - uint8_t*& dst) const { +void GradientCache::mixFloats(const FloatColor& start, const FloatColor& end, + float amount, uint8_t*& dst) const { float oppAmount = 1.0f - amount; float* d = (float*) dst; +#if ANDROID_LINEAR_BLENDING_ENABLED *d++ = start.r * oppAmount + end.r * amount; *d++ = start.g * oppAmount + end.g * amount; *d++ = start.b * oppAmount + end.b * amount; +#else + *d++ = OECF_sRGB(start.r * oppAmount + end.r * amount); + *d++ = OECF_sRGB(start.g * oppAmount + end.g * amount); + *d++ = OECF_sRGB(start.b * oppAmount + end.b * amount); +#endif *d++ = start.a * oppAmount + end.a * amount; dst += 4 * sizeof(float); } @@ -217,10 +223,10 @@ void GradientCache::generateTexture(uint32_t* colors, float* positions, ChannelMixer mix = gMixers[mUseFloatTexture]; FloatColor start; - start.set(colors[0]); + start.setSRGB(colors[0]); FloatColor end; - end.set(colors[1]); + end.setSRGB(colors[1]); int currentPos = 1; float startPos = positions[0]; @@ -235,7 +241,7 @@ void GradientCache::generateTexture(uint32_t* colors, float* positions, currentPos++; - end.set(colors[currentPos]); + end.setSRGB(colors[currentPos]); distance = positions[currentPos] - startPos; } diff --git a/libs/hwui/GradientCache.h b/libs/hwui/GradientCache.h index 3fd8e80dd64b..5e35435ed64c 100644 --- a/libs/hwui/GradientCache.h +++ b/libs/hwui/GradientCache.h @@ -154,11 +154,13 @@ private: size_t bytesPerPixel() const; size_t sourceBytesPerPixel() const; - typedef void (GradientCache::*ChannelMixer)(FloatColor& start, FloatColor& end, + typedef void (GradientCache::*ChannelMixer)(const FloatColor& start, const FloatColor& end, float amount, uint8_t*& dst) const; - void mixBytes(FloatColor& start, FloatColor& end, float amount, uint8_t*& dst) const; - void mixFloats(FloatColor& start, FloatColor& end, float amount, uint8_t*& dst) const; + void mixBytes(const FloatColor& start, const FloatColor& end, + float amount, uint8_t*& dst) const; + void mixFloats(const FloatColor& start, const FloatColor& end, + float amount, uint8_t*& dst) const; LruCache<GradientCacheEntry, Texture*> mCache; diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp index 315c60eccb3e..4ef6b85de9ad 100644 --- a/libs/hwui/ProgramCache.cpp +++ b/libs/hwui/ProgramCache.cpp @@ -163,25 +163,31 @@ const char* gFS_Uniforms_HasRoundRectClip = // When we are writing to an sRGB framebuffer, we must do the following: // EOCF(OECF(color) + dither) // We approximate the transfer functions with gamma 2.0 to avoid branches and pow() -// The dithering pattern is generated with a triangle noise generator in the range [-0.5,1.5[ +// The dithering pattern is generated with a triangle noise generator in the range [-0.0,1.0] // TODO: Handle linear fp16 render targets -const char* gFS_Dither_Functions = - "\nmediump float triangleNoise(const highp vec2 n) {\n" +const char* gFS_Gradient_Functions = + "\nfloat triangleNoise(const highp vec2 n) {\n" " highp vec2 p = fract(n * vec2(5.3987, 5.4421));\n" " p += dot(p.yx, p.xy + vec2(21.5351, 14.3137));\n" " highp float xy = p.x * p.y;\n" - " return fract(xy * 95.4307) + fract(xy * 75.04961) - 0.5;\n" + " return fract(xy * 95.4307) + fract(xy * 75.04961) - 1.0;\n" "}\n"; -const char* gFS_Dither_Preamble[2] = { +const char* gFS_Gradient_Preamble[2] = { // Linear framebuffer "\nvec4 dither(const vec4 color) {\n" " return vec4(color.rgb + (triangleNoise(gl_FragCoord.xy * screenSize.xy) / 255.0), color.a);" + "}\n" + "\nvec4 gammaMix(const vec4 a, const vec4 b, float v) {\n" + " return pow(mix(a, b, v), vec4(vec3(1.0 / 2.2), 1.0));" "}\n", // sRGB framebuffer "\nvec4 dither(const vec4 color) {\n" " vec3 dithered = sqrt(color.rgb) + (triangleNoise(gl_FragCoord.xy * screenSize.xy) / 255.0);\n" " return vec4(dithered * dithered, color.a);\n" "}\n" + "\nvec4 gammaMix(const vec4 a, const vec4 b, float v) {\n" + " return mix(a, b, v);" + "}\n" }; // Uses luminance coefficients from Rec.709 to choose the appropriate gamma @@ -239,7 +245,7 @@ const char* gFS_Fast_SingleGradient[2] = { " gl_FragColor = dither(texture2D(gradientSampler, linear));\n" "}\n\n", "\nvoid main(void) {\n" - " gl_FragColor = dither(mix(startColor, endColor, clamp(linear, 0.0, 1.0)));\n" + " gl_FragColor = dither(gammaMix(startColor, endColor, clamp(linear, 0.0, 1.0)));\n" "}\n\n", }; const char* gFS_Fast_SingleModulateGradient[2] = { @@ -247,7 +253,7 @@ const char* gFS_Fast_SingleModulateGradient[2] = { " gl_FragColor = dither(color.a * texture2D(gradientSampler, linear));\n" "}\n\n", "\nvoid main(void) {\n" - " gl_FragColor = dither(color.a * mix(startColor, endColor, clamp(linear, 0.0, 1.0)));\n" + " gl_FragColor = dither(color.a * gammaMix(startColor, endColor, clamp(linear, 0.0, 1.0)));\n" "}\n\n" }; @@ -279,19 +285,19 @@ const char* gFS_Main_FetchGradient[6] = { // Linear " vec4 gradientColor = texture2D(gradientSampler, linear);\n", - " vec4 gradientColor = mix(startColor, endColor, clamp(linear, 0.0, 1.0));\n", + " vec4 gradientColor = gammaMix(startColor, endColor, clamp(linear, 0.0, 1.0));\n", // Circular " vec4 gradientColor = texture2D(gradientSampler, vec2(length(circular), 0.5));\n", - " vec4 gradientColor = mix(startColor, endColor, clamp(length(circular), 0.0, 1.0));\n", + " vec4 gradientColor = gammaMix(startColor, endColor, clamp(length(circular), 0.0, 1.0));\n", // Sweep " highp float index = atan(sweep.y, sweep.x) * 0.15915494309; // inv(2 * PI)\n" " vec4 gradientColor = texture2D(gradientSampler, vec2(index - floor(index), 0.5));\n", " highp float index = atan(sweep.y, sweep.x) * 0.15915494309; // inv(2 * PI)\n" - " vec4 gradientColor = mix(startColor, endColor, clamp(index - floor(index), 0.0, 1.0));\n" + " vec4 gradientColor = gammaMix(startColor, endColor, clamp(index - floor(index), 0.0, 1.0));\n" }; const char* gFS_Main_FetchBitmap = " vec4 bitmapColor = texture2D(bitmapSampler, outBitmapTexCoords);\n"; @@ -665,8 +671,8 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti } fast = true; } else if (singleGradient) { - shader.append(gFS_Dither_Functions); - shader.append(gFS_Dither_Preamble[mHasSRGB]); + shader.append(gFS_Gradient_Functions); + shader.append(gFS_Gradient_Preamble[mHasSRGB]); if (!description.modulate) { shader.append(gFS_Fast_SingleGradient[description.isSimpleGradient]); } else { @@ -705,8 +711,8 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti generateTextureWrap(shader, description.bitmapWrapS, description.bitmapWrapT); } if (description.hasGradient) { - shader.append(gFS_Dither_Functions); - shader.append(gFS_Dither_Preamble[mHasSRGB]); + shader.append(gFS_Gradient_Functions); + shader.append(gFS_Gradient_Preamble[mHasSRGB]); } // Begin the shader diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp index 9838df2f6013..5d9e5c035283 100644 --- a/libs/hwui/SkiaShader.cpp +++ b/libs/hwui/SkiaShader.cpp @@ -173,8 +173,8 @@ bool tryStoreGradient(Caches& caches, const SkShader& shader, const Matrix4 mode outData->gradientSampler = 0; outData->gradientTexture = nullptr; - outData->startColor.set(gradInfo.fColors[0]); - outData->endColor.set(gradInfo.fColors[1]); + outData->startColor.setSRGB(gradInfo.fColors[0]); + outData->endColor.setSRGB(gradInfo.fColors[1]); } return true; diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp index 4e5b9ad2f0a3..a2f3cb6b3d85 100644 --- a/libs/hwui/VectorDrawable.cpp +++ b/libs/hwui/VectorDrawable.cpp @@ -202,7 +202,9 @@ void FullPath::drawPath(SkCanvas* outCanvas, SkPath& renderPath, float strokeSca if (properties.getFillGradient() != nullptr) { paint.setColor(applyAlpha(SK_ColorBLACK, properties.getFillAlpha())); SkShader* newShader = properties.getFillGradient()->newWithLocalMatrix(matrix); - paint.setShader(newShader); + // newWithLocalMatrix(...) creates a new SkShader and returns a bare pointer. We need to + // remove the extra ref so that the ref count is correctly managed. + paint.setShader(newShader)->unref(); needsFill = true; } else if (properties.getFillColor() != SK_ColorTRANSPARENT) { paint.setColor(applyAlpha(properties.getFillColor(), properties.getFillAlpha())); @@ -222,7 +224,9 @@ void FullPath::drawPath(SkCanvas* outCanvas, SkPath& renderPath, float strokeSca if (properties.getStrokeGradient() != nullptr) { paint.setColor(applyAlpha(SK_ColorBLACK, properties.getStrokeAlpha())); SkShader* newShader = properties.getStrokeGradient()->newWithLocalMatrix(matrix); - paint.setShader(newShader); + // newWithLocalMatrix(...) creates a new SkShader and returns a bare pointer. We need to + // remove the extra ref so that the ref count is correctly managed. + paint.setShader(newShader)->unref(); needsStroke = true; } else if (properties.getStrokeColor() != SK_ColorTRANSPARENT) { paint.setColor(applyAlpha(properties.getStrokeColor(), properties.getStrokeAlpha())); diff --git a/libs/hwui/tests/unit/VectorDrawableTests.cpp b/libs/hwui/tests/unit/VectorDrawableTests.cpp index 83b485fa705e..8e0d3ee572a6 100644 --- a/libs/hwui/tests/unit/VectorDrawableTests.cpp +++ b/libs/hwui/tests/unit/VectorDrawableTests.cpp @@ -426,5 +426,49 @@ TEST(VectorDrawable, groupProperties) { EXPECT_EQ(1.0f, properties->getPivotY()); } + +static SkShader* createShader(bool* isDestroyed) { + class TestShader : public SkShader { + public: + TestShader(bool* isDestroyed) : SkShader(), mDestroyed(isDestroyed) { + } + ~TestShader() { + *mDestroyed = true; + } + + Factory getFactory() const override { return nullptr; } + private: + bool* mDestroyed; + }; + return new TestShader(isDestroyed); +} + +TEST(VectorDrawable, drawPathWithoutIncrementingShaderRefCount) { + VectorDrawable::FullPath path("m1 1", 4); + SkBitmap bitmap; + SkImageInfo info = SkImageInfo::Make(5, 5, kN32_SkColorType, kPremul_SkAlphaType); + bitmap.setInfo(info); + bitmap.allocPixels(info); + SkCanvas canvas(bitmap); + + bool shaderIsDestroyed = false; + + // Initial ref count is 1 + SkShader* shader = createShader(&shaderIsDestroyed); + + // Setting the fill gradient increments the ref count of the shader by 1 + path.mutateStagingProperties()->setFillGradient(shader); + path.draw(&canvas, SkMatrix::I(), 1.0f, 1.0f, true); + // Resetting the fill gradient decrements the ref count of the shader by 1 + path.mutateStagingProperties()->setFillGradient(nullptr); + + // Expect ref count to be 1 again, i.e. nothing else to have a ref to the shader now. Unref() + // again should bring the ref count to zero and consequently trigger detor. + shader->unref(); + + // Verify that detor is called. + EXPECT_TRUE(shaderIsDestroyed); +} + }; // namespace uirenderer }; // namespace android diff --git a/libs/hwui/utils/Color.h b/libs/hwui/utils/Color.h index c8f8c7071075..f9cc46d1cf30 100644 --- a/libs/hwui/utils/Color.h +++ b/libs/hwui/utils/Color.h @@ -85,10 +85,17 @@ namespace uirenderer { // Opto-electronic conversion function for the sRGB color space // Takes a gamma-encoded sRGB value and converts it to a linear sRGB value static constexpr float OECF_sRGB(float linear) { -#ifdef ANDROID_ENABLE_LINEAR_BLENDING // IEC 61966-2-1:1999 return linear <= 0.0031308f ? linear * 12.92f : (powf(linear, 1.0f / 2.4f) * 1.055f) - 0.055f; + } + + // Opto-electronic conversion function for the sRGB color space + // Takes a gamma-encoded sRGB value and converts it to a linear sRGB value + // This function returns the input unmodified if linear blending is not enabled + static constexpr float OECF(float linear) { +#ifdef ANDROID_ENABLE_LINEAR_BLENDING + return OECF_sRGB(linear); #else return linear; #endif @@ -97,9 +104,16 @@ namespace uirenderer { // Electro-optical conversion function for the sRGB color space // Takes a linear sRGB value and converts it to a gamma-encoded sRGB value static constexpr float EOCF_sRGB(float srgb) { -#ifdef ANDROID_ENABLE_LINEAR_BLENDING // IEC 61966-2-1:1999 return srgb <= 0.04045f ? srgb / 12.92f : powf((srgb + 0.055f) / 1.055f, 2.4f); + } + + // Electro-optical conversion function for the sRGB color space + // Takes a linear sRGB value and converts it to a gamma-encoded sRGB value + // This function returns the input unmodified if linear blending is not enabled + static constexpr float EOCF(float srgb) { +#ifdef ANDROID_ENABLE_LINEAR_BLENDING + return EOCF_sRGB(srgb); #else return srgb; #endif diff --git a/packages/SettingsLib/res/layout/restricted_switch_preference.xml b/packages/SettingsLib/res/layout/restricted_switch_preference.xml index 89dc10bf34a6..bb1d90614d5a 100644 --- a/packages/SettingsLib/res/layout/restricted_switch_preference.xml +++ b/packages/SettingsLib/res/layout/restricted_switch_preference.xml @@ -20,7 +20,7 @@ android:gravity="center_vertical" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" - android:background="?android:attr/activatedBackgroundIndicator" + android:background="?android:attr/selectableItemBackground" android:clipToPadding="false"> <LinearLayout diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index e3ede4642e5a..77c60fb84d8f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -264,10 +264,12 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } } mOccluded = occluded; - mPhoneStatusBar.updateMediaMetaData(false, animate && !occluded); + if (mShowing) { + mPhoneStatusBar.updateMediaMetaData(false, animate && !occluded); + } mStatusBarWindowManager.setKeyguardOccluded(occluded); reset(); - if (animate && !occluded) { + if (animate && !occluded && mShowing) { mPhoneStatusBar.animateKeyguardUnoccluding(); } } diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java index 2d6bef4fb735..72feab7cd5c9 100644 --- a/services/core/java/com/android/server/content/SyncManager.java +++ b/services/core/java/com/android/server/content/SyncManager.java @@ -795,7 +795,17 @@ public class SyncManager { * Use {@link AuthorityInfo#UNDEFINED} to sync all authorities. */ public void scheduleSync(Account requestedAccount, int userId, int reason, - String requestedAuthority, Bundle extras, int targetSyncState) { + String requestedAuthority, Bundle extras, int targetSyncState) { + scheduleSync(requestedAccount, userId, reason, requestedAuthority, extras, targetSyncState, + 0 /* min delay */); + } + + /** + * @param minDelayMillis The sync can't land before this delay expires. + */ + private void scheduleSync(Account requestedAccount, int userId, int reason, + String requestedAuthority, Bundle extras, int targetSyncState, + final long minDelayMillis) { final boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE); if (extras == null) { extras = new Bundle(); @@ -906,7 +916,7 @@ public class SyncManager { if (result != null && result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT)) { scheduleSync(account.account, userId, reason, authority, - finalExtras, targetSyncState); + finalExtras, targetSyncState, minDelayMillis); } } )); @@ -967,7 +977,8 @@ public class SyncManager { postScheduleSyncMessage( new SyncOperation(account.account, account.userId, owningUid, owningPackage, reason, source, - authority, newExtras, allowParallelSyncs) + authority, newExtras, allowParallelSyncs), + minDelayMillis ); } else if (targetSyncState == AuthorityInfo.UNDEFINED || targetSyncState == isSyncable) { @@ -982,7 +993,8 @@ public class SyncManager { postScheduleSyncMessage( new SyncOperation(account.account, account.userId, owningUid, owningPackage, reason, source, - authority, extras, allowParallelSyncs) + authority, extras, allowParallelSyncs), + minDelayMillis ); } } @@ -1088,14 +1100,14 @@ public class SyncManager { } /** - * Schedule sync based on local changes to a provider. Occurs within interval - * [LOCAL_SYNC_DELAY, 2*LOCAL_SYNC_DELAY]. + * Schedule sync based on local changes to a provider. We wait for at least LOCAL_SYNC_DELAY + * ms to batch syncs. */ public void scheduleLocalSync(Account account, int userId, int reason, String authority) { final Bundle extras = new Bundle(); extras.putBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD, true); scheduleSync(account, userId, reason, authority, extras, - AuthorityInfo.UNDEFINED); + AuthorityInfo.UNDEFINED, LOCAL_SYNC_DELAY); } public SyncAdapterType[] getSyncAdapterTypes(int userId) { @@ -1152,9 +1164,10 @@ public class SyncManager { mSyncHandler.sendMessageDelayed(monitorMessage, SYNC_MONITOR_WINDOW_LENGTH_MILLIS); } - private void postScheduleSyncMessage(SyncOperation syncOperation) { - mSyncHandler.obtainMessage(mSyncHandler.MESSAGE_SCHEDULE_SYNC, syncOperation) - .sendToTarget(); + private void postScheduleSyncMessage(SyncOperation syncOperation, long minDelayMillis) { + ScheduleSyncMessagePayload payload = + new ScheduleSyncMessagePayload(syncOperation, minDelayMillis); + mSyncHandler.obtainMessage(mSyncHandler.MESSAGE_SCHEDULE_SYNC, payload).sendToTarget(); } /** @@ -1194,6 +1207,16 @@ public class SyncManager { } } + private static class ScheduleSyncMessagePayload { + final SyncOperation syncOperation; + final long minDelayMillis; + + ScheduleSyncMessagePayload(SyncOperation syncOperation, long minDelayMillis) { + this.syncOperation = syncOperation; + this.minDelayMillis = minDelayMillis; + } + } + private void clearBackoffSetting(EndPoint target) { Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(target); if (backoff != null && backoff.first == SyncStorageEngine.NOT_IN_BACKOFF_MODE && @@ -1262,7 +1285,7 @@ public class SyncManager { if (!op.isPeriodic && op.target.matchesSpec(target)) { count++; getJobScheduler().cancel(op.jobId); - postScheduleSyncMessage(op); + postScheduleSyncMessage(op, 0 /* min delay */); } } if (Log.isLoggable(TAG, Log.VERBOSE)) { @@ -2417,8 +2440,10 @@ public class SyncManager { mDataConnectionIsConnected = readDataConnectionState(); switch (msg.what) { case MESSAGE_SCHEDULE_SYNC: - SyncOperation op = (SyncOperation) msg.obj; - scheduleSyncOperationH(op); + ScheduleSyncMessagePayload syncPayload = + (ScheduleSyncMessagePayload) msg.obj; + SyncOperation op = syncPayload.syncOperation; + scheduleSyncOperationH(op, syncPayload.minDelayMillis); break; case MESSAGE_START_SYNC: @@ -3101,7 +3126,8 @@ public class SyncManager { maybeRescheduleSync(syncResult, syncOperation); } else { // create a normal sync instance that will respect adapter backoffs - postScheduleSyncMessage(syncOperation.createOneTimeSyncOperation()); + postScheduleSyncMessage(syncOperation.createOneTimeSyncOperation(), + 0 /* min delay */); } historyMessage = ContentResolver.syncErrorToString( syncResultToErrorNumber(syncResult)); diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 0c7c8aa8a9b5..4d72d8e75df7 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -3641,7 +3641,7 @@ public class NotificationManagerService extends SystemService { if (pkg != null && !r.sbn.getPackageName().equals(pkg)) { continue; } - if (channelId == null || !channelId.equals(r.getChannel().getId())) { + if (channelId != null && !channelId.equals(r.getChannel().getId())) { continue; } if (canceledNotifications == null) { diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 339325be32c7..1c00cc36f34b 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -5484,6 +5484,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD; mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; return true; + } else if (wasOccluded != isOccluded) { + mKeyguardOccluded = isOccluded; + mKeyguardDelegate.setOccluded(isOccluded, false /* animate */); + return false; } else { return false; } diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 7e09c163fc5f..454b025bbd7f 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -1184,16 +1184,16 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } } - int rebuildWindowListUnchecked(DisplayContent dc, int addIndex) { - return super.rebuildWindowList(dc, addIndex); + int rebuildWindowListUnchecked(int addIndex) { + return super.rebuildWindowList(addIndex); } @Override - int rebuildWindowList(DisplayContent dc, int addIndex) { + int rebuildWindowList(int addIndex) { if (mIsExiting && !waitingForReplacement()) { return addIndex; } - return rebuildWindowListUnchecked(dc, addIndex); + return rebuildWindowListUnchecked(addIndex); } @Override diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 8b720e002f51..6f7f4a97ad00 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1122,13 +1122,13 @@ class DisplayContent extends WindowContainer<TaskStack> { AppTokenList exitingAppTokens = mChildren.get(stackNdx).mExitingAppTokens; int NT = exitingAppTokens.size(); for (int j = 0; j < NT; j++) { - i = exitingAppTokens.get(j).rebuildWindowListUnchecked(this, i); + i = exitingAppTokens.get(j).rebuildWindowListUnchecked(i); } } // And add in the still active app tokens in Z order. for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) { - i = mChildren.get(stackNdx).rebuildWindowList(this, i); + i = mChildren.get(stackNdx).rebuildWindowList(i); } i -= lastBelow; diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 56bf6cd58c4f..981b813b6030 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -483,16 +483,15 @@ class WindowContainer<E extends WindowContainer> implements Comparable<WindowCon /** * Rebuilds the WindowList for the input display content. - * @param dc The display content to rebuild the window list for. * @param addIndex The index in the window list to add the next entry to. * @return The next index in the window list to. */ // TODO: Hoping we can get rid of WindowList so this method wouldn't be needed. - int rebuildWindowList(DisplayContent dc, int addIndex) { + int rebuildWindowList(int addIndex) { final int count = mChildren.size(); for (int i = 0; i < count; i++) { final WindowContainer wc = mChildren.get(i); - addIndex = wc.rebuildWindowList(dc, addIndex); + addIndex = wc.rebuildWindowList(addIndex); } return addIndex; } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index b02d1f7ae0dc..c899490a0c8c 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1257,7 +1257,8 @@ public class WindowManagerService extends IWindowManager.Stub // excercise to find the appropriate input method target (used for animations // and dialog adjustments), but for purposes of Z ordering we simply wish to // place it above the docked divider. Unless it is already above the divider. - WindowState dockedDivider = w.mDisplayContent.mDividerControllerLocked.getWindow(); + final WindowState dockedDivider = + w.getDisplayContent().mDividerControllerLocked.getWindow(); if (dockedDivider != null && dockedDivider.isVisibleLw()) { int dividerIndex = windows.indexOf(dockedDivider); if (dividerIndex > 0 && dividerIndex > i) { @@ -1275,7 +1276,7 @@ public class WindowManagerService extends IWindowManager.Stub return -1; } - void addInputMethodWindowToListLocked(WindowState win) { + private void addInputMethodWindowToListLocked(WindowState win) { int pos = findDesiredInputMethodWindowIndexLocked(true); if (pos >= 0) { if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( @@ -1654,7 +1655,7 @@ public class WindowManagerService extends IWindowManager.Stub } WindowState win = new WindowState(this, session, client, token, parentWindow, - appOp[0], seq, attrs, viewVisibility, displayContent, session.mUid); + appOp[0], seq, attrs, viewVisibility, session.mUid); if (win.mDeathRecipient == null) { // Client has apparently died, so there is no reason to // continue. diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index a784a8fe44a6..272bc9dc7984 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -71,6 +71,7 @@ import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_ import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION; import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; +import static android.view.WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW; import static android.view.WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON; import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND; import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; @@ -468,10 +469,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP boolean mHasSurface = false; - private boolean mNotOnAppsDisplay = false; - // TODO: Get this from WindowToken? Done in ag/1522894 - DisplayContent mDisplayContent; - /** When true this window can be displayed on screens owther than mOwnerUid's */ private boolean mShowToOwnerOnly; @@ -564,7 +561,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, WindowState parentWindow, int appOp, int seq, WindowManager.LayoutParams a, - int viewVisibility, final DisplayContent displayContent, int ownerId) { + int viewVisibility, int ownerId) { mService = service; mSession = s; mClient = c; @@ -588,7 +585,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP }; mAttrs.copyFrom(a); mViewVisibility = viewVisibility; - mDisplayContent = displayContent; mPolicy = mService.mPolicy; mContext = mService.mContext; DeathRecipient deathRecipient = new DeathRecipient(); @@ -644,15 +640,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } mIsFloatingLayer = mIsImWindow || mIsWallpaper; - if (mAppToken != null) { - final DisplayContent appDisplay = getDisplayContent(); - mNotOnAppsDisplay = displayContent != appDisplay; - - if (mAppToken.showForAllUsers) { - // Windows for apps that can show for all users should also show when the - // device is locked. - mAttrs.flags |= FLAG_SHOW_WHEN_LOCKED; - } + if (mAppToken != null && mAppToken.showForAllUsers) { + // Windows for apps that can show for all users should also show when the device is + // locked. + mAttrs.flags |= FLAG_SHOW_WHEN_LOCKED; } mWinAnimator = new WindowStateAnimator(this); @@ -667,7 +658,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mLayer = 0; mInputWindowHandle = new InputWindowHandle( mAppToken != null ? mAppToken.mInputApplicationHandle : null, this, - displayContent.getDisplayId()); + getDisplayContent().getDisplayId()); } void attach() { @@ -715,6 +706,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP final Task task = getTask(); final boolean fullscreenTask = !isInMultiWindowMode(); final boolean windowsAreFloating = task != null && task.isFloating(); + final DisplayContent dc = getDisplayContent(); // If the task has temp inset bounds set, we have to make sure all its windows uses // the temp inset frame. Otherwise different display frames get applied to the main @@ -780,8 +772,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP layoutXDiff = !mInsetFrame.isEmpty() ? mInsetFrame.left - mContainingFrame.left : 0; layoutYDiff = !mInsetFrame.isEmpty() ? mInsetFrame.top - mContainingFrame.top : 0; layoutContainingFrame = !mInsetFrame.isEmpty() ? mInsetFrame : mContainingFrame; - mTmpRect.set(0, 0, mDisplayContent.getDisplayInfo().logicalWidth, - mDisplayContent.getDisplayInfo().logicalHeight); + mTmpRect.set(0, 0, dc.getDisplayInfo().logicalWidth, dc.getDisplayInfo().logicalHeight); subtractInsets(mDisplayFrame, layoutContainingFrame, df, mTmpRect); if (!layoutInParentFrame()) { subtractInsets(mContainingFrame, layoutContainingFrame, pf, mTmpRect); @@ -853,7 +844,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mVisibleFrame.set(mContentFrame); mStableFrame.set(mContentFrame); } else if (mAttrs.type == TYPE_DOCK_DIVIDER) { - mDisplayContent.getDockedDividerController().positionDockedStackedDivider(mFrame); + dc.getDockedDividerController().positionDockedStackedDivider(mFrame); mContentFrame.set(mFrame); if (!mFrame.equals(mLastFrame)) { mMovedByResize = true; @@ -1188,20 +1179,16 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } } - public DisplayContent getDisplayContent() { - if (mAppToken == null || mNotOnAppsDisplay) { - return mDisplayContent; - } - final TaskStack stack = getStack(); - return stack == null ? mDisplayContent : stack.getDisplayContent(); + DisplayContent getDisplayContent() { + return mToken.getDisplayContent(); } - public DisplayInfo getDisplayInfo() { + DisplayInfo getDisplayInfo() { final DisplayContent displayContent = getDisplayContent(); return displayContent != null ? displayContent.getDisplayInfo() : null; } - public int getDisplayId() { + int getDisplayId() { final DisplayContent displayContent = getDisplayContent(); if (displayContent == null) { return -1; @@ -1222,8 +1209,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } // Some system windows (e.g. "Power off" dialog) don't have a task, but we would still // associate them with some stack to enable dimming. - return mAttrs.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW - && mDisplayContent != null ? mDisplayContent.getHomeStack() : null; + final DisplayContent dc = getDisplayContent(); + return mAttrs.type >= FIRST_SYSTEM_WINDOW && dc != null ? dc.getHomeStack() : null; } /** @@ -2001,12 +1988,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } void scheduleAnimationIfDimming() { - if (mDisplayContent == null) { + final DisplayContent dc = getDisplayContent(); + if (dc == null) { return; } final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser(); - if (dimLayerUser != null && mDisplayContent.mDimLayerController.isDimming( - dimLayerUser, mWinAnimator)) { + if (dimLayerUser != null && dc.mDimLayerController.isDimming(dimLayerUser, mWinAnimator)) { // Force an animation pass just to update the mDimLayer layer. mService.scheduleAnimationLocked(); } @@ -2119,16 +2106,17 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return; } + final DisplayContent dc = getDisplayContent(); if (!mAnimatingExit && mAppDied) { // If app died visible, apply a dim over the window to indicate that it's inactive - mDisplayContent.mDimLayerController.applyDimAbove(getDimLayerUser(), mWinAnimator); + dc.mDimLayerController.applyDimAbove(getDimLayerUser(), mWinAnimator); } else if ((mAttrs.flags & FLAG_DIM_BEHIND) != 0 - && mDisplayContent != null && !mAnimatingExit && isVisibleUnchecked()) { - mDisplayContent.mDimLayerController.applyDimBehind(getDimLayerUser(), mWinAnimator); + && dc != null && !mAnimatingExit && isVisibleUnchecked()) { + dc.mDimLayerController.applyDimBehind(getDimLayerUser(), mWinAnimator); } } - DimLayer.DimLayerUser getDimLayerUser() { + private DimLayer.DimLayerUser getDimLayerUser() { Task task = getTask(); if (task != null) { return task; @@ -2187,8 +2175,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } void setDisplayLayoutNeeded() { - if (mDisplayContent != null) { - mDisplayContent.setLayoutNeeded(); + final DisplayContent dc = getDisplayContent(); + if (dc != null) { + dc.setLayoutNeeded(); } } @@ -2909,18 +2898,19 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP @Override public boolean isDimming() { final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser(); - return dimLayerUser != null && mDisplayContent != null && - mDisplayContent.mDimLayerController.isDimming(dimLayerUser, mWinAnimator); + final DisplayContent dc = getDisplayContent(); + return dimLayerUser != null && dc != null + && dc.mDimLayerController.isDimming(dimLayerUser, mWinAnimator); } - public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) { + void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) { mShowToOwnerOnly = showToOwnerOnly; } boolean isHiddenFromUserLocked() { // Child windows are evaluated based on their parent window. final WindowState win = getTopParentWindow(); - if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW + if (win.mAttrs.type < FIRST_SYSTEM_WINDOW && win.mAppToken != null && win.mAppToken.showForAllUsers) { // All window frames that are fullscreen extend above status bar, but some don't extend @@ -3215,7 +3205,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP * @return Whether we reported "resize while not drag resizing" to the application. * @see #isResizedWhileNotDragResizing() */ - boolean isResizedWhileNotDragResizingReported() { + private boolean isResizedWhileNotDragResizingReported() { return mResizedWhileNotDragResizingReported; } @@ -3223,7 +3213,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return mResizeMode; } - boolean computeDragResizing() { + private boolean computeDragResizing() { final Task task = getTask(); if (task == null) { return false; @@ -3241,7 +3231,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // and the bounds we clip this window to might be different. In order to avoid holes, we // simulate that we are still resizing so the app fills the hole with the resizing // background. - return (mDisplayContent.mDividerControllerLocked.isResizing() + return (getDisplayContent().mDividerControllerLocked.isResizing() || mAppToken != null && !mAppToken.mFrozenBounds.isEmpty()) && !task.inFreeformWorkspace() && !isGoneForLayoutLw(); @@ -3257,7 +3247,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP if (task != null && task.isDragResizing()) { mResizeMode = task.getDragResizeMode(); } else { - mResizeMode = mDragResizing && mDisplayContent.mDividerControllerLocked.isResizing() + mResizeMode = mDragResizing && getDisplayContent().mDividerControllerLocked.isResizing() ? DRAG_RESIZE_MODE_DOCKED_DIVIDER : DRAG_RESIZE_MODE_FREEFORM; } @@ -3277,9 +3267,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP if (stack != null) { pw.print(" stackId="); pw.print(stack.mStackId); } - if (mNotOnAppsDisplay) { - pw.print(" mNotOnAppsDisplay="); pw.print(mNotOnAppsDisplay); - } pw.print(" mSession="); pw.print(mSession); pw.print(" mClient="); pw.println(mClient.asBinder()); pw.print(prefix); pw.print("mOwnerUid="); pw.print(mOwnerUid); @@ -3665,9 +3652,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } void requestUpdateWallpaperIfNeeded() { - if (mDisplayContent != null && (mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) { - mDisplayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; - mDisplayContent.setLayoutNeeded(); + final DisplayContent dc = getDisplayContent(); + if (dc != null && (mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) { + dc.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; + dc.setLayoutNeeded(); mService.mWindowPlacerLocked.requestTraversal(); } @@ -3693,12 +3681,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return winY; } - void transferDimToReplacement() { + private void transferDimToReplacement() { final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser(); - if (dimLayerUser != null && mDisplayContent != null) { - mDisplayContent.mDimLayerController.applyDim(dimLayerUser, - mReplacementWindow.mWinAnimator, - (mAttrs.flags & FLAG_DIM_BEHIND) != 0 ? true : false); + final DisplayContent dc = getDisplayContent(); + if (dimLayerUser != null && dc != null) { + dc.mDimLayerController.applyDim(dimLayerUser, + mReplacementWindow.mWinAnimator, (mAttrs.flags & FLAG_DIM_BEHIND) != 0); } } @@ -3796,13 +3784,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } if (mAttrs.type == TYPE_INPUT_METHOD) { - mDisplayContent.mDividerControllerLocked.resetImeHideRequested(); + getDisplayContent().mDividerControllerLocked.resetImeHideRequested(); } return true; } - void logPerformShow(String prefix) { + private void logPerformShow(String prefix) { if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW && mAttrs.type == TYPE_APPLICATION_STARTING)) { Slog.v(TAG, prefix + this @@ -3812,11 +3800,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP + " during animation: policyVis=" + mPolicyVisibility + " parentHidden=" + isParentWindowHidden() + " tok.hiddenRequested=" - + (mAppToken != null ? mAppToken.hiddenRequested : false) - + " tok.hidden=" + (mAppToken != null ? mAppToken.hidden : false) + + (mAppToken != null && mAppToken.hiddenRequested) + + " tok.hidden=" + (mAppToken != null && mAppToken.hidden) + " animating=" + mWinAnimator.mAnimating + " tok animating=" - + (mWinAnimator.mAppAnimator != null ? mWinAnimator.mAppAnimator.animating : false) + + (mWinAnimator.mAppAnimator != null && mWinAnimator.mAppAnimator.animating) + " Callers=" + Debug.getCallers(4)); } } @@ -3874,13 +3862,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } @Override - int rebuildWindowList(DisplayContent dc, int addIndex) { - final DisplayContent winDisplayContent = getDisplayContent(); - if (winDisplayContent == dc || winDisplayContent == null) { - mDisplayContent = dc; - return reAddWindow(addIndex); - } - return addIndex; + int rebuildWindowList(int addIndex) { + return reAddWindow(addIndex); } // TODO: come-up with a better name for this method that represents what it does. diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 1fae77d46189..65bfbf462dbe 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -1750,7 +1750,7 @@ class WindowStateAnimator { Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); if (mWin.mAttrs.type == TYPE_INPUT_METHOD) { - mWin.mDisplayContent.adjustForImeIfNeeded(); + mWin.getDisplayContent().adjustForImeIfNeeded(); if (isEntrance) { mWin.setDisplayLayoutNeeded(); mService.mWindowPlacerLocked.requestTraversal(); diff --git a/services/core/jni/Android.mk b/services/core/jni/Android.mk index c18f07b74dc3..b3bfc16e6320 100644 --- a/services/core/jni/Android.mk +++ b/services/core/jni/Android.mk @@ -69,3 +69,6 @@ LOCAL_SHARED_LIBRARIES += \ libutils \ android.hardware.power@1.0 \ +LOCAL_SHARED_LIBRARIES += \ + libhidl libhwbinder android.hardware.vibrator@1.0 + diff --git a/services/core/jni/com_android_server_VibratorService.cpp b/services/core/jni/com_android_server_VibratorService.cpp index 03fbd19094ba..cc5226090fe2 100644 --- a/services/core/jni/com_android_server_VibratorService.cpp +++ b/services/core/jni/com_android_server_VibratorService.cpp @@ -16,6 +16,9 @@ #define LOG_TAG "VibratorService" +#include <android/hardware/vibrator/1.0/IVibrator.h> +#include <android/hardware/vibrator/1.0/types.h> + #include "jni.h" #include "JNIHelp.h" #include "android_runtime/AndroidRuntime.h" @@ -26,32 +29,27 @@ #include <stdio.h> +using android::hardware::getService; +using android::hardware::vibrator::V1_0::IVibrator; +using android::hardware::vibrator::V1_0::Status; + namespace android { -static hw_module_t *gVibraModule = NULL; -static vibrator_device_t *gVibraDevice = NULL; +static sp<IVibrator> mHal; static void vibratorInit(JNIEnv /* env */, jobject /* clazz */) { - if (gVibraModule != NULL) { + /* TODO(b/31632518) */ + if (mHal != nullptr) { return; } - - int err = hw_get_module(VIBRATOR_HARDWARE_MODULE_ID, (hw_module_t const**)&gVibraModule); - - if (err) { - ALOGE("Couldn't load %s module (%s)", VIBRATOR_HARDWARE_MODULE_ID, strerror(-err)); - } else { - if (gVibraModule) { - vibrator_open(gVibraModule, &gVibraDevice); - } - } + mHal = IVibrator::getService("vibrator"); } static jboolean vibratorExists(JNIEnv* /* env */, jobject /* clazz */) { - if (gVibraModule && gVibraDevice) { + if (mHal != nullptr) { return JNI_TRUE; } else { return JNI_FALSE; @@ -60,10 +58,10 @@ static jboolean vibratorExists(JNIEnv* /* env */, jobject /* clazz */) static void vibratorOn(JNIEnv* /* env */, jobject /* clazz */, jlong timeout_ms) { - if (gVibraDevice) { - int err = gVibraDevice->vibrator_on(gVibraDevice, timeout_ms); - if (err != 0) { - ALOGE("The hw module failed in vibrator_on: %s", strerror(-err)); + if (mHal != nullptr) { + Status retStatus = mHal->on(timeout_ms); + if (retStatus == Status::ERR) { + ALOGE("vibratorOn command failed."); } } else { ALOGW("Tried to vibrate but there is no vibrator device."); @@ -72,10 +70,10 @@ static void vibratorOn(JNIEnv* /* env */, jobject /* clazz */, jlong timeout_ms) static void vibratorOff(JNIEnv* /* env */, jobject /* clazz */) { - if (gVibraDevice) { - int err = gVibraDevice->vibrator_off(gVibraDevice); - if (err != 0) { - ALOGE("The hw module failed in vibrator_off(): %s", strerror(-err)); + if (mHal != nullptr) { + Status retStatus = mHal->off(); + if (retStatus == Status::ERR) { + ALOGE("vibratorOff command failed."); } } else { ALOGW("Tried to stop vibrating but there is no vibrator device."); diff --git a/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java index 1df71b571668..74e8c9d52836 100644 --- a/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java @@ -76,8 +76,7 @@ public class AppWindowTokenTests { private WindowState createWindow(WindowState parent, int type, WindowToken token) { final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(type); - return new WindowState(sWm, null, mIWindow, token, parent, 0, 0, attrs, 0, - sWm.getDefaultDisplayContentLocked(), 0); + return new WindowState(sWm, null, mIWindow, token, parent, 0, 0, attrs, 0, 0); } /* Used so we can gain access to some protected members of the {@link AppWindowToken} class */ diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java index 106989bc2cca..3df1df980a26 100644 --- a/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java @@ -163,7 +163,6 @@ public class WindowStateTests { private WindowState createWindow(WindowState parent, int type) { final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(type); - return new WindowState(sWm, null, mIWindow, mWindowToken, parent, 0, 0, attrs, 0, - sWm.getDefaultDisplayContentLocked(), 0); + return new WindowState(sWm, null, mIWindow, mWindowToken, parent, 0, 0, attrs, 0, 0); } } diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowTokenTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowTokenTests.java index fcc59bcb430e..1a4dff9c0c07 100644 --- a/services/tests/servicestests/src/com/android/server/wm/WindowTokenTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowTokenTests.java @@ -157,8 +157,7 @@ public class WindowTokenTests { private WindowState createWindow(WindowState parent, int type, WindowToken token) { final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(type); - return new WindowState(mWm, null, mIWindow, token, parent, 0, 0, attrs, 0, - mWm.getDefaultDisplayContentLocked(), 0); + return new WindowState(mWm, null, mIWindow, token, parent, 0, 0, attrs, 0, 0); } /* Used so we can gain access to some protected members of the {@link WindowToken} class */ diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java index a4aab7c268b0..da27ea916a18 100644 --- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java +++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java @@ -87,6 +87,11 @@ public class NotificationTestList extends TestActivity } private Test[] mTests = new Test[] { + new Test("cancel all") { + public void run() { + mNM.cancelAll(); + } + }, new Test("Phone call") { public void run() { |