diff options
Diffstat (limited to 'core/java')
232 files changed, 2811 insertions, 1872 deletions
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java index 3f1845a..9d6aa13 100644 --- a/core/java/android/accessibilityservice/AccessibilityService.java +++ b/core/java/android/accessibilityservice/AccessibilityService.java @@ -27,7 +27,6 @@ import android.os.RemoteException; import android.util.Log; import android.view.KeyEvent; import android.view.WindowManager; -import android.view.WindowManagerGlobal; import android.view.WindowManagerImpl; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityInteractionClient; diff --git a/core/java/android/animation/AnimatorInflater.java b/core/java/android/animation/AnimatorInflater.java index d5ae6c6..021194c 100644 --- a/core/java/android/animation/AnimatorInflater.java +++ b/core/java/android/animation/AnimatorInflater.java @@ -43,7 +43,6 @@ import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.util.ArrayList; -import java.util.List; /** * This class is used to instantiate animator XML files into Animator objects. diff --git a/core/java/android/animation/FloatKeyframeSet.java b/core/java/android/animation/FloatKeyframeSet.java index abac246..56da940 100644 --- a/core/java/android/animation/FloatKeyframeSet.java +++ b/core/java/android/animation/FloatKeyframeSet.java @@ -18,7 +18,6 @@ package android.animation; import android.animation.Keyframe.FloatKeyframe; -import java.util.ArrayList; import java.util.List; /** diff --git a/core/java/android/animation/IntKeyframeSet.java b/core/java/android/animation/IntKeyframeSet.java index 0ec5138..12a4bf9 100644 --- a/core/java/android/animation/IntKeyframeSet.java +++ b/core/java/android/animation/IntKeyframeSet.java @@ -18,7 +18,6 @@ package android.animation; import android.animation.Keyframe.IntKeyframe; -import java.util.ArrayList; import java.util.List; /** diff --git a/core/java/android/animation/KeyframeSet.java b/core/java/android/animation/KeyframeSet.java index 0e99bff..c80e162 100644 --- a/core/java/android/animation/KeyframeSet.java +++ b/core/java/android/animation/KeyframeSet.java @@ -16,7 +16,6 @@ package android.animation; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/core/java/android/animation/Keyframes.java b/core/java/android/animation/Keyframes.java index c921466..c149bed 100644 --- a/core/java/android/animation/Keyframes.java +++ b/core/java/android/animation/Keyframes.java @@ -15,7 +15,6 @@ */ package android.animation; -import java.util.ArrayList; import java.util.List; /** diff --git a/core/java/android/animation/ObjectAnimator.java b/core/java/android/animation/ObjectAnimator.java index 71855da..87ad49b 100644 --- a/core/java/android/animation/ObjectAnimator.java +++ b/core/java/android/animation/ObjectAnimator.java @@ -24,7 +24,6 @@ import android.util.Log; import android.util.Property; import java.lang.ref.WeakReference; -import java.util.ArrayList; /** * This subclass of {@link ValueAnimator} provides support for animating properties on target objects. diff --git a/core/java/android/animation/PropertyValuesHolder.java b/core/java/android/animation/PropertyValuesHolder.java index bd7bca0..8928e99 100644 --- a/core/java/android/animation/PropertyValuesHolder.java +++ b/core/java/android/animation/PropertyValuesHolder.java @@ -25,10 +25,8 @@ import android.util.Property; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.concurrent.locks.ReentrantReadWriteLock; /** * This class holds information about a property and the values that that property diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java index 292bb1d..118af64 100644 --- a/core/java/android/animation/ValueAnimator.java +++ b/core/java/android/animation/ValueAnimator.java @@ -16,8 +16,6 @@ package android.animation; -import android.content.res.ConfigurationBoundResourceCache; -import android.os.Debug; import android.os.Looper; import android.os.Trace; import android.util.AndroidRuntimeException; diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java index 4cdd397..94e3b66 100644 --- a/core/java/android/app/ActionBar.java +++ b/core/java/android/app/ActionBar.java @@ -33,14 +33,10 @@ import android.view.KeyEvent; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; -import android.view.ViewGroup.MarginLayoutParams; import android.view.Window; import android.widget.SpinnerAdapter; -import android.widget.Toolbar; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.util.Map; /** * A primary toolbar within the activity that may display the activity title, application-level diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index f0d98f8..a36d34a 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -34,8 +34,6 @@ import com.android.internal.app.IVoiceInteractor; import com.android.internal.app.WindowDecorActionBar; import com.android.internal.app.ToolbarActionBar; -import android.annotation.IntDef; -import android.annotation.Nullable; import android.annotation.SystemApi; import android.app.admin.DevicePolicyManager; import android.content.ComponentCallbacks2; diff --git a/core/java/android/app/ActivityTransitionCoordinator.java b/core/java/android/app/ActivityTransitionCoordinator.java index e3b27b5..2939322 100644 --- a/core/java/android/app/ActivityTransitionCoordinator.java +++ b/core/java/android/app/ActivityTransitionCoordinator.java @@ -206,7 +206,6 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { private ArrayList<GhostViewListeners> mGhostViewListeners = new ArrayList<GhostViewListeners>(); private ArrayMap<View, Float> mOriginalAlphas = new ArrayMap<View, Float>(); - final private ArrayList<View> mRootSharedElements = new ArrayList<View>(); private ArrayList<Matrix> mSharedElementParentMatrices; public ActivityTransitionCoordinator(Window window, @@ -253,17 +252,10 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { final String name = sharedElements.keyAt(i); if (isFirstRun && (view == null || !view.isAttachedToWindow() || name == null)) { sharedElements.removeAt(i); - } else { - if (!isNested(view, sharedElements)) { - mSharedElementNames.add(name); - mSharedElements.add(view); - sharedElements.removeAt(i); - if (isFirstRun) { - // We need to keep track which shared elements are roots - // and which are nested. - mRootSharedElements.add(view); - } - } + } else if (!isNested(view, sharedElements)) { + mSharedElementNames.add(name); + mSharedElements.add(view); + sharedElements.removeAt(i); } } isFirstRun = false; @@ -520,24 +512,9 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { } private void getSharedElementParentMatrix(View view, Matrix matrix) { - final boolean isNestedInOtherSharedElement = !mRootSharedElements.contains(view); - final boolean useParentMatrix; - if (isNestedInOtherSharedElement) { - useParentMatrix = true; - } else { - final int index = mSharedElementParentMatrices == null ? -1 - : mSharedElements.indexOf(view); - if (index < 0) { - useParentMatrix = true; - } else { - // The indices of mSharedElementParentMatrices matches the - // mSharedElement matrices. - Matrix parentMatrix = mSharedElementParentMatrices.get(index); - matrix.set(parentMatrix); - useParentMatrix = false; - } - } - if (useParentMatrix) { + final int index = mSharedElementParentMatrices == null ? -1 + : mSharedElements.indexOf(view); + if (index < 0) { matrix.reset(); ViewParent viewParent = view.getParent(); if (viewParent instanceof ViewGroup) { @@ -545,6 +522,11 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { ViewGroup parent = (ViewGroup) viewParent; parent.transformMatrixToLocal(matrix); } + } else { + // The indices of mSharedElementParentMatrices matches the + // mSharedElement matrices. + Matrix parentMatrix = mSharedElementParentMatrices.get(index); + matrix.set(parentMatrix); } } @@ -701,7 +683,6 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { mResultReceiver = null; mPendingTransition = null; mListener = null; - mRootSharedElements.clear(); mSharedElementParentMatrices = null; } @@ -817,9 +798,12 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { ViewGroup decor = getDecor(); if (decor != null) { boolean moveWithParent = moveSharedElementWithParent(); + Matrix tempMatrix = new Matrix(); for (int i = 0; i < numSharedElements; i++) { View view = mSharedElements.get(i); - GhostView.addGhost(view, decor); + tempMatrix.reset(); + mSharedElementParentMatrices.get(i).invert(tempMatrix); + GhostView.addGhost(view, decor, tempMatrix); ViewGroup parent = (ViewGroup) view.getParent(); if (moveWithParent && !isInTransitionGroup(parent, decor)) { GhostViewListeners listener = new GhostViewListeners(view, parent, decor); diff --git a/core/java/android/app/ActivityTransitionState.java b/core/java/android/app/ActivityTransitionState.java index a2bfa4e..5c6fe46 100644 --- a/core/java/android/app/ActivityTransitionState.java +++ b/core/java/android/app/ActivityTransitionState.java @@ -18,7 +18,6 @@ package android.app; import android.os.Bundle; import android.os.ResultReceiver; import android.transition.Transition; -import android.util.ArrayMap; import android.util.SparseArray; import android.view.View; import android.view.ViewGroup; diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java index 2c596e5..5dd02ae 100644 --- a/core/java/android/app/AlarmManager.java +++ b/core/java/android/app/AlarmManager.java @@ -26,7 +26,6 @@ import android.os.Parcelable; import android.os.RemoteException; import android.os.UserHandle; import android.os.WorkSource; -import android.os.Parcelable.Creator; /** * This class provides access to the system alarm services. These allow you diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java index c8f58c6..3e545f9 100644 --- a/core/java/android/app/AlertDialog.java +++ b/core/java/android/app/AlertDialog.java @@ -38,6 +38,8 @@ import android.widget.Button; import android.widget.ListAdapter; import android.widget.ListView; +import com.android.internal.R; + /** * A subclass of Dialog that can display one, two or three buttons. If you only want to * display a String in this dialog box, use the setMessage() method. If you @@ -48,7 +50,7 @@ import android.widget.ListView; * FrameLayout fl = (FrameLayout) findViewById(android.R.id.custom); * fl.addView(myView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT)); * </pre> - * + * * <p>The AlertDialog class takes care of automatically setting * {@link WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM * WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM} for you based on whether @@ -70,31 +72,46 @@ public class AlertDialog extends Dialog implements DialogInterface { /** * Special theme constant for {@link #AlertDialog(Context, int)}: use * the traditional (pre-Holo) alert dialog theme. + * + * @deprecated Use {@link android.R.style#Theme_Material_Dialog_Alert}. */ + @Deprecated public static final int THEME_TRADITIONAL = 1; - + /** * Special theme constant for {@link #AlertDialog(Context, int)}: use * the holographic alert theme with a dark background. + * + * @deprecated Use {@link android.R.style#Theme_Material_Dialog_Alert}. */ + @Deprecated public static final int THEME_HOLO_DARK = 2; - + /** * Special theme constant for {@link #AlertDialog(Context, int)}: use * the holographic alert theme with a light background. + * + * @deprecated Use {@link android.R.style#Theme_Material_Light_Dialog_Alert}. */ + @Deprecated public static final int THEME_HOLO_LIGHT = 3; /** * Special theme constant for {@link #AlertDialog(Context, int)}: use * the device's default alert theme with a dark background. + * + * @deprecated Use {@link android.R.style#Theme_DeviceDefault_Dialog_Alert}. */ + @Deprecated public static final int THEME_DEVICE_DEFAULT_DARK = 4; /** * Special theme constant for {@link #AlertDialog(Context, int)}: use * the device's default alert theme with a light background. + * + * @deprecated Use {@link android.R.style#Theme_DeviceDefault_Light_Dialog_Alert}. */ + @Deprecated public static final int THEME_DEVICE_DEFAULT_LIGHT = 5; /** @@ -108,55 +125,92 @@ public class AlertDialog extends Dialog implements DialogInterface { * @hide */ public static final int LAYOUT_HINT_SIDE = 1; - + + /** + * Creates an alert dialog that uses the default alert dialog theme. + * <p> + * The default alert dialog theme is defined by + * {@link android.R.attr#alertDialogTheme} within the parent + * {@code context}'s theme. + * + * @param context the parent context + */ protected AlertDialog(Context context) { - this(context, resolveDialogTheme(context, 0), true); + this(context, 0); } /** - * Construct an AlertDialog that uses an explicit theme. The actual style - * that an AlertDialog uses is a private implementation, however you can - * here supply either the name of an attribute in the theme from which - * to get the dialog's style (such as {@link android.R.attr#alertDialogTheme} - * or one of the constants {@link #THEME_TRADITIONAL}, - * {@link #THEME_HOLO_DARK}, or {@link #THEME_HOLO_LIGHT}. + * Creates an alert dialog that uses the default alert dialog theme and a + * custom cancel listener. + * <p> + * This is functionally identical to: + * <pre> + * AlertDialog dialog = new AlertDialog(context); + * alertDialog.setCancelable(cancelable); + * alertDialog.setOnCancelListener(cancelListener); + * </pre> + * <p> + * The default alert dialog theme is defined by + * {@link android.R.attr#alertDialogTheme} within the parent + * {@code context}'s theme. + * + * @param context the parent context */ - protected AlertDialog(Context context, @AttrRes int theme) { - this(context, theme, true); + protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { + this(context, 0); + + setCancelable(cancelable); + setOnCancelListener(cancelListener); } - AlertDialog(Context context, int theme, boolean createThemeContextWrapper) { - super(context, resolveDialogTheme(context, theme), createThemeContextWrapper); + /** + * Creates an alert dialog that uses an explicit theme resource. + * <p> + * The specified theme resource ({@code themeResId}) is applied on top of + * the parent {@code context}'s theme. It may be specified as a style + * resource containing a fully-populated theme, such as + * {@link android.R.style#Theme_Material_Dialog}, to replace all attributes + * in the parent {@code context}'s theme including primary and accent + * colors. + * <p> + * To preserve attributes such as primary and accent colors, the + * {@code themeResId} may instead be specified as an overlay theme such as + * {@link android.R.style#ThemeOverlay_Material_Dialog}. This will override + * only the window attributes necessary to style the alert window as a + * dialog. + * <p> + * Alternatively, the {@code themeResId} may be specified as {@code 0} to + * use the parent {@code context}'s resolved value for + * {@link android.R.attr#alertDialogTheme}. + * + * @param context the parent context + * @param themeResId the resource ID of the theme against which to inflate + * this dialog, or {@code 0} to use the parent + * {@code context}'s default alert dialog theme + */ + protected AlertDialog(Context context, @AttrRes int themeResId) { + super(context, resolveDialogTheme(context, themeResId)); mWindow.alwaysReadCloseOnTouchAttr(); mAlert = new AlertController(getContext(), this, getWindow()); } - protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { - super(context, resolveDialogTheme(context, 0)); - mWindow.alwaysReadCloseOnTouchAttr(); - setCancelable(cancelable); - setOnCancelListener(cancelListener); - mAlert = new AlertController(context, this, getWindow()); - } - - static int resolveDialogTheme(Context context, int resid) { - if (resid == THEME_TRADITIONAL) { - return com.android.internal.R.style.Theme_Dialog_Alert; - } else if (resid == THEME_HOLO_DARK) { - return com.android.internal.R.style.Theme_Holo_Dialog_Alert; - } else if (resid == THEME_HOLO_LIGHT) { - return com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert; - } else if (resid == THEME_DEVICE_DEFAULT_DARK) { - return com.android.internal.R.style.Theme_DeviceDefault_Dialog_Alert; - } else if (resid == THEME_DEVICE_DEFAULT_LIGHT) { - return com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog_Alert; - } else if (resid >= 0x01000000) { // start of real resource IDs. - return resid; + static int resolveDialogTheme(Context context, int themeResId) { + if (themeResId == THEME_TRADITIONAL) { + return R.style.Theme_Dialog_Alert; + } else if (themeResId == THEME_HOLO_DARK) { + return R.style.Theme_Holo_Dialog_Alert; + } else if (themeResId == THEME_HOLO_LIGHT) { + return R.style.Theme_Holo_Light_Dialog_Alert; + } else if (themeResId == THEME_DEVICE_DEFAULT_DARK) { + return R.style.Theme_DeviceDefault_Dialog_Alert; + } else if (themeResId == THEME_DEVICE_DEFAULT_LIGHT) { + return R.style.Theme_DeviceDefault_Light_Dialog_Alert; + } else if (themeResId >= 0x01000000) { // start of real resource IDs. + return themeResId; } else { - TypedValue outValue = new TypedValue(); - context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme, - outValue, true); + final TypedValue outValue = new TypedValue(); + context.getTheme().resolveAttribute(R.attr.alertDialogTheme, outValue, true); return outValue.resourceId; } } @@ -177,13 +231,13 @@ public class AlertDialog extends Dialog implements DialogInterface { /** * Gets the list view used in the dialog. - * + * * @return The {@link ListView} from the dialog. */ public ListView getListView() { return mAlert.getListView(); } - + @Override public void setTitle(CharSequence title) { super.setTitle(title); @@ -196,7 +250,7 @@ public class AlertDialog extends Dialog implements DialogInterface { public void setCustomTitle(View customTitleView) { mAlert.setCustomTitle(customTitleView); } - + public void setMessage(CharSequence message) { mAlert.setMessage(message); } @@ -207,9 +261,9 @@ public class AlertDialog extends Dialog implements DialogInterface { public void setView(View view) { mAlert.setView(view); } - + /** - * Set the view to display in that dialog, specifying the spacing to appear around that + * Set the view to display in that dialog, specifying the spacing to appear around that * view. * * @param view The view to show in the content area of the dialog @@ -233,7 +287,7 @@ public class AlertDialog extends Dialog implements DialogInterface { /** * Set a message to be sent when a button is pressed. - * + * * @param whichButton Which button to set the message for, can be one of * {@link DialogInterface#BUTTON_POSITIVE}, * {@link DialogInterface#BUTTON_NEGATIVE}, or @@ -244,10 +298,10 @@ public class AlertDialog extends Dialog implements DialogInterface { public void setButton(int whichButton, CharSequence text, Message msg) { mAlert.setButton(whichButton, text, null, msg); } - + /** * Set a listener to be invoked when the positive button of the dialog is pressed. - * + * * @param whichButton Which button to set the listener on, can be one of * {@link DialogInterface#BUTTON_POSITIVE}, * {@link DialogInterface#BUTTON_NEGATIVE}, or @@ -267,7 +321,7 @@ public class AlertDialog extends Dialog implements DialogInterface { public void setButton(CharSequence text, Message msg) { setButton(BUTTON_POSITIVE, text, msg); } - + /** * @deprecated Use {@link #setButton(int, CharSequence, Message)} with * {@link DialogInterface#BUTTON_NEGATIVE}. @@ -288,7 +342,7 @@ public class AlertDialog extends Dialog implements DialogInterface { /** * Set a listener to be invoked when button 1 of the dialog is pressed. - * + * * @param text The text to display in button 1. * @param listener The {@link DialogInterface.OnClickListener} to use. * @deprecated Use @@ -334,7 +388,7 @@ public class AlertDialog extends Dialog implements DialogInterface { public void setIcon(@DrawableRes int resId) { mAlert.setIcon(resId); } - + public void setIcon(Drawable icon) { mAlert.setIcon(icon); } @@ -353,7 +407,7 @@ public class AlertDialog extends Dialog implements DialogInterface { public void setInverseBackgroundForced(boolean forceInverseBackground) { mAlert.setInverseBackgroundForced(forceInverseBackground); } - + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -371,35 +425,57 @@ public class AlertDialog extends Dialog implements DialogInterface { if (mAlert.onKeyUp(keyCode, event)) return true; return super.onKeyUp(keyCode, event); } - + public static class Builder { private final AlertController.AlertParams P; - private int mTheme; - + private int mThemeResId; + /** - * Constructor using a context for this builder and the {@link AlertDialog} it creates. + * Creates a builder for an alert dialog that uses the default alert + * dialog theme. + * <p> + * The default alert dialog theme is defined by + * {@link android.R.attr#alertDialogTheme} within the parent + * {@code context}'s theme. + * + * @param context the parent context */ public Builder(Context context) { this(context, resolveDialogTheme(context, 0)); } /** - * Constructor using a context and theme for this builder and - * the {@link AlertDialog} it creates. The actual theme - * that an AlertDialog uses is a private implementation, however you can - * here supply either the name of an attribute in the theme from which - * to get the dialog's style (such as {@link android.R.attr#alertDialogTheme} - * or one of the constants - * {@link AlertDialog#THEME_TRADITIONAL AlertDialog.THEME_TRADITIONAL}, - * {@link AlertDialog#THEME_HOLO_DARK AlertDialog.THEME_HOLO_DARK}, or - * {@link AlertDialog#THEME_HOLO_LIGHT AlertDialog.THEME_HOLO_LIGHT}. + * Creates a builder for an alert dialog that uses an explicit theme + * resource. + * <p> + * The specified theme resource ({@code themeResId}) is applied on top + * of the parent {@code context}'s theme. It may be specified as a + * style resource containing a fully-populated theme, such as + * {@link android.R.style#Theme_Material_Dialog}, to replace all + * attributes in the parent {@code context}'s theme including primary + * and accent colors. + * <p> + * To preserve attributes such as primary and accent colors, the + * {@code themeResId} may instead be specified as an overlay theme such + * as {@link android.R.style#ThemeOverlay_Material_Dialog}. This will + * override only the window attributes necessary to style the alert + * window as a dialog. + * <p> + * Alternatively, the {@code themeResId} may be specified as {@code 0} + * to use the parent {@code context}'s resolved value for + * {@link android.R.attr#alertDialogTheme}. + * + * @param context the parent context + * @param themeResId the resource ID of the theme against which to inflate + * this dialog, or {@code 0} to use the parent + * {@code context}'s default alert dialog theme */ - public Builder(Context context, int theme) { + public Builder(Context context, int themeResId) { P = new AlertController.AlertParams(new ContextThemeWrapper( - context, resolveDialogTheme(context, theme))); - mTheme = theme; + context, resolveDialogTheme(context, themeResId))); + mThemeResId = themeResId; } - + /** * Returns a {@link Context} with the appropriate theme for dialogs created by this Builder. * Applications should use this Context for obtaining LayoutInflaters for inflating views @@ -421,7 +497,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mTitle = P.mContext.getText(titleId); return this; } - + /** * Set the title displayed in the {@link Dialog}. * @@ -431,23 +507,28 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mTitle = title; return this; } - + /** - * Set the title using the custom view {@code customTitleView}. The - * methods {@link #setTitle(int)} and {@link #setIcon(int)} should be - * sufficient for most titles, but this is provided if the title needs - * more customization. Using this will replace the title and icon set - * via the other methods. - * - * @param customTitleView The custom view to use as the title. + * Set the title using the custom view {@code customTitleView}. + * <p> + * The methods {@link #setTitle(int)} and {@link #setIcon(int)} should + * be sufficient for most titles, but this is provided if the title + * needs more customization. Using this will replace the title and icon + * set via the other methods. + * <p> + * <strong>Note:</strong> To ensure consistent styling, the custom view + * should be inflated or constructed using the alert dialog's themed + * context obtained via {@link #getContext()}. * - * @return This Builder object to allow for chaining of calls to set methods + * @param customTitleView the custom view to use as the title + * @return this Builder object to allow for chaining of calls to set + * methods */ public Builder setCustomTitle(View customTitleView) { P.mCustomTitleView = customTitleView; return this; } - + /** * Set the message to display using the given resource id. * @@ -457,7 +538,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mMessage = P.mContext.getText(messageId); return this; } - + /** * Set the message to display. * @@ -467,7 +548,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mMessage = message; return this; } - + /** * Set the resource id of the {@link Drawable} to be used in the title. * <p> @@ -479,11 +560,16 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mIconId = iconId; return this; } - + /** * Set the {@link Drawable} to be used in the title. - * - * @return This Builder object to allow for chaining of calls to set methods + * <p> + * <strong>Note:</strong> To ensure consistent styling, the drawable + * should be inflated or constructed using the alert dialog's themed + * context obtained via {@link #getContext()}. + * + * @return this Builder object to allow for chaining of calls to set + * methods */ public Builder setIcon(Drawable icon) { P.mIcon = icon; @@ -518,7 +604,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mPositiveButtonListener = listener; return this; } - + /** * Set a listener to be invoked when the positive button of the dialog is pressed. * @param text The text to display in the positive button @@ -531,7 +617,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mPositiveButtonListener = listener; return this; } - + /** * Set a listener to be invoked when the negative button of the dialog is pressed. * @param textId The resource id of the text to display in the negative button @@ -544,7 +630,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mNegativeButtonListener = listener; return this; } - + /** * Set a listener to be invoked when the negative button of the dialog is pressed. * @param text The text to display in the negative button @@ -557,7 +643,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mNegativeButtonListener = listener; return this; } - + /** * Set a listener to be invoked when the neutral button of the dialog is pressed. * @param textId The resource id of the text to display in the neutral button @@ -570,7 +656,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mNeutralButtonListener = listener; return this; } - + /** * Set a listener to be invoked when the neutral button of the dialog is pressed. * @param text The text to display in the neutral button @@ -583,7 +669,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mNeutralButtonListener = listener; return this; } - + /** * Sets whether the dialog is cancelable or not. Default is true. * @@ -593,7 +679,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mCancelable = cancelable; return this; } - + /** * Sets the callback that will be called if the dialog is canceled. * @@ -611,7 +697,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mOnCancelListener = onCancelListener; return this; } - + /** * Sets the callback that will be called when the dialog is dismissed for any reason. * @@ -631,7 +717,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mOnKeyListener = onKeyListener; return this; } - + /** * Set a list of items to be displayed in the dialog as the content, you will be notified of the * selected item via the supplied listener. This should be an array type i.e. R.array.foo @@ -643,7 +729,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mOnClickListener = listener; return this; } - + /** * Set a list of items to be displayed in the dialog as the content, you will be notified of the * selected item via the supplied listener. @@ -655,12 +741,12 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mOnClickListener = listener; return this; } - + /** * Set a list of items, which are supplied by the given {@link ListAdapter}, to be * displayed in the dialog as the content, you will be notified of the * selected item via the supplied listener. - * + * * @param adapter The {@link ListAdapter} to supply the list of items * @param listener The listener that will be called when an item is clicked. * @@ -671,12 +757,12 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mOnClickListener = listener; return this; } - + /** * Set a list of items, which are supplied by the given {@link Cursor}, to be * displayed in the dialog as the content, you will be notified of the * selected item via the supplied listener. - * + * * @param cursor The {@link Cursor} to supply the list of items * @param listener The listener that will be called when an item is clicked. * @param labelColumn The column name on the cursor containing the string to display @@ -691,7 +777,7 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mOnClickListener = listener; return this; } - + /** * Set a list of items to be displayed in the dialog as the content, * you will be notified of the selected item via the supplied listener. @@ -699,7 +785,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * a check mark displayed to the right of the text for each checked * item. Clicking on an item in the list will not dismiss the dialog. * Clicking on a button will dismiss the dialog. - * + * * @param itemsId the resource id of an array i.e. R.array.foo * @param checkedItems specifies which items are checked. It should be null in which case no * items are checked. If non null it must be exactly the same length as the array of @@ -718,14 +804,14 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mIsMultiChoice = true; return this; } - + /** * Set a list of items to be displayed in the dialog as the content, * you will be notified of the selected item via the supplied listener. * The list will have a check mark displayed to the right of the text * for each checked item. Clicking on an item in the list will not * dismiss the dialog. Clicking on a button will dismiss the dialog. - * + * * @param items the text of the items to be displayed in the list. * @param checkedItems specifies which items are checked. It should be null in which case no * items are checked. If non null it must be exactly the same length as the array of @@ -736,7 +822,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * * @return This Builder object to allow for chaining of calls to set methods */ - public Builder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, + public Builder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, final OnMultiChoiceClickListener listener) { P.mItems = items; P.mOnCheckboxClickListener = listener; @@ -744,14 +830,14 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mIsMultiChoice = true; return this; } - + /** * Set a list of items to be displayed in the dialog as the content, * you will be notified of the selected item via the supplied listener. * The list will have a check mark displayed to the right of the text * for each checked item. Clicking on an item in the list will not * dismiss the dialog. Clicking on a button will dismiss the dialog. - * + * * @param cursor the cursor used to provide the items. * @param isCheckedColumn specifies the column name on the cursor to use to determine * whether a checkbox is checked or not. It must return an integer value where 1 @@ -764,7 +850,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * * @return This Builder object to allow for chaining of calls to set methods */ - public Builder setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, + public Builder setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, final OnMultiChoiceClickListener listener) { P.mCursor = cursor; P.mOnCheckboxClickListener = listener; @@ -773,14 +859,14 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mIsMultiChoice = true; return this; } - + /** * Set a list of items to be displayed in the dialog as the content, you will be notified of * the selected item via the supplied listener. This should be an array type i.e. * R.array.foo The list will have a check mark displayed to the right of the text for the * checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a * button will dismiss the dialog. - * + * * @param itemsId the resource id of an array i.e. R.array.foo * @param checkedItem specifies which item is checked. If -1 no items are checked. * @param listener notified when an item on the list is clicked. The dialog will not be @@ -797,13 +883,13 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mIsSingleChoice = true; return this; } - + /** * Set a list of items to be displayed in the dialog as the content, you will be notified of * the selected item via the supplied listener. The list will have a check mark displayed to * the right of the text for the checked item. Clicking on an item in the list will not * dismiss the dialog. Clicking on a button will dismiss the dialog. - * + * * @param cursor the cursor to retrieve the items from. * @param checkedItem specifies which item is checked. If -1 no items are checked. * @param labelColumn The column name on the cursor containing the string to display in the @@ -814,7 +900,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * * @return This Builder object to allow for chaining of calls to set methods */ - public Builder setSingleChoiceItems(Cursor cursor, int checkedItem, String labelColumn, + public Builder setSingleChoiceItems(Cursor cursor, int checkedItem, String labelColumn, final OnClickListener listener) { P.mCursor = cursor; P.mOnClickListener = listener; @@ -823,13 +909,13 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mIsSingleChoice = true; return this; } - + /** * Set a list of items to be displayed in the dialog as the content, you will be notified of * the selected item via the supplied listener. The list will have a check mark displayed to * the right of the text for the checked item. Clicking on an item in the list will not * dismiss the dialog. Clicking on a button will dismiss the dialog. - * + * * @param items the items to be displayed. * @param checkedItem specifies which item is checked. If -1 no items are checked. * @param listener notified when an item on the list is clicked. The dialog will not be @@ -844,14 +930,14 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mCheckedItem = checkedItem; P.mIsSingleChoice = true; return this; - } - + } + /** * Set a list of items to be displayed in the dialog as the content, you will be notified of * the selected item via the supplied listener. The list will have a check mark displayed to * the right of the text for the checked item. Clicking on an item in the list will not * dismiss the dialog. Clicking on a button will dismiss the dialog. - * + * * @param adapter The {@link ListAdapter} to supply the list of items * @param checkedItem specifies which item is checked. If -1 no items are checked. * @param listener notified when an item on the list is clicked. The dialog will not be @@ -867,26 +953,25 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mIsSingleChoice = true; return this; } - + /** * Sets a listener to be invoked when an item in the list is selected. - * - * @param listener The listener to be invoked. - * @see AdapterView#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) * - * @return This Builder object to allow for chaining of calls to set methods + * @param listener the listener to be invoked + * @return this Builder object to allow for chaining of calls to set methods + * @see AdapterView#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) */ public Builder setOnItemSelectedListener(final AdapterView.OnItemSelectedListener listener) { P.mOnItemSelectedListener = listener; return this; } - + /** * Set a custom view resource to be the contents of the Dialog. The * resource will be inflated, adding all top-level views to the screen. * * @param layoutResId Resource ID to be inflated. - * @return This Builder object to allow for chaining of calls to set + * @return this Builder object to allow for chaining of calls to set * methods */ public Builder setView(int layoutResId) { @@ -897,12 +982,18 @@ public class AlertDialog extends Dialog implements DialogInterface { } /** - * Set a custom view to be the contents of the Dialog. If the supplied view is an instance - * of a {@link ListView} the light background will be used. + * Sets a custom view to be the contents of the alert dialog. + * <p> + * When using a pre-Holo theme, if the supplied view is an instance of + * a {@link ListView} then the light background will be used. + * <p> + * <strong>Note:</strong> To ensure consistent styling, the custom view + * should be inflated or constructed using the alert dialog's themed + * context obtained via {@link #getContext()}. * - * @param view The view to use as the contents of the Dialog. - * - * @return This Builder object to allow for chaining of calls to set methods + * @param view the view to use as the contents of the alert dialog + * @return this Builder object to allow for chaining of calls to set + * methods */ public Builder setView(View view) { P.mView = view; @@ -910,29 +1001,34 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mViewSpacingSpecified = false; return this; } - - /** - * Set a custom view to be the contents of the Dialog, specifying the - * spacing to appear around that view. If the supplied view is an - * instance of a {@link ListView} the light background will be used. - * - * @param view The view to use as the contents of the Dialog. - * @param viewSpacingLeft Spacing between the left edge of the view and - * the dialog frame - * @param viewSpacingTop Spacing between the top edge of the view and - * the dialog frame - * @param viewSpacingRight Spacing between the right edge of the view - * and the dialog frame - * @param viewSpacingBottom Spacing between the bottom edge of the view - * and the dialog frame - * @return This Builder object to allow for chaining of calls to set + + /** + * Sets a custom view to be the contents of the alert dialog and + * specifies additional padding around that view. + * <p> + * When using a pre-Holo theme, if the supplied view is an instance of + * a {@link ListView} then the light background will be used. + * <p> + * <strong>Note:</strong> To ensure consistent styling, the custom view + * should be inflated or constructed using the alert dialog's themed + * context obtained via {@link #getContext()}. + * + * @param view the view to use as the contents of the alert dialog + * @param viewSpacingLeft spacing between the left edge of the view and + * the dialog frame + * @param viewSpacingTop spacing between the top edge of the view and + * the dialog frame + * @param viewSpacingRight spacing between the right edge of the view + * and the dialog frame + * @param viewSpacingBottom spacing between the bottom edge of the view + * and the dialog frame + * @return this Builder object to allow for chaining of calls to set * methods - * - * - * This is currently hidden because it seems like people should just - * be able to put padding around the view. - * @hide + * + * @hide Remove once the framework usages have been replaced. + * @deprecated Set the padding on the view itself. */ + @Deprecated public Builder setView(View view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight, int viewSpacingBottom) { P.mView = view; @@ -944,15 +1040,18 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mViewSpacingBottom = viewSpacingBottom; return this; } - + /** - * Sets the Dialog to use the inverse background, regardless of what the - * contents is. - * - * @param useInverseBackground Whether to use the inverse background - * - * @return This Builder object to allow for chaining of calls to set methods + * Sets the alert dialog to use the inverse background, regardless of + * what the contents is. + * + * @param useInverseBackground whether to use the inverse background + * @return this Builder object to allow for chaining of calls to set methods + * @deprecated This flag is only used for pre-Material themes. Instead, + * specify the window background using on the alert dialog + * theme. */ + @Deprecated public Builder setInverseBackgroundForced(boolean useInverseBackground) { P.mForceInverseBackground = useInverseBackground; return this; @@ -968,13 +1067,15 @@ public class AlertDialog extends Dialog implements DialogInterface { /** - * Creates a {@link AlertDialog} with the arguments supplied to this builder. It does not - * {@link Dialog#show()} the dialog. This allows the user to do any extra processing - * before displaying the dialog. Use {@link #show()} if you don't have any other processing - * to do and want this to be created and displayed. + * Creates an {@link AlertDialog} with the arguments supplied to this + * builder. + * <p> + * Calling this method does not display the dialog. If no additional + * processing is needed, {@link #show()} may be called instead to both + * create and display the dialog. */ public AlertDialog create() { - final AlertDialog dialog = new AlertDialog(P.mContext, mTheme, false); + final AlertDialog dialog = new AlertDialog(P.mContext, mThemeResId); P.apply(dialog.mAlert); dialog.setCancelable(P.mCancelable); if (P.mCancelable) { @@ -989,14 +1090,20 @@ public class AlertDialog extends Dialog implements DialogInterface { } /** - * Creates a {@link AlertDialog} with the arguments supplied to this builder and - * {@link Dialog#show()}'s the dialog. + * Creates an {@link AlertDialog} with the arguments supplied to this + * builder and immediately displays the dialog. + * <p> + * Calling this method is functionally identical to: + * <pre> + * AlertDialog dialog = builder.create(); + * dialog.show(); + * </pre> */ public AlertDialog show() { - AlertDialog dialog = create(); + final AlertDialog dialog = create(); dialog.show(); return dialog; } } - + } diff --git a/core/java/android/app/AppImportanceMonitor.java b/core/java/android/app/AppImportanceMonitor.java index c760e1e..e0d0d8d 100644 --- a/core/java/android/app/AppImportanceMonitor.java +++ b/core/java/android/app/AppImportanceMonitor.java @@ -22,8 +22,6 @@ import android.os.Looper; import android.os.Message; import android.os.RemoteException; import android.util.SparseArray; -import android.util.SparseIntArray; - import java.util.List; /** diff --git a/core/java/android/app/BackStackRecord.java b/core/java/android/app/BackStackRecord.java index 2784d44..83451aa 100644 --- a/core/java/android/app/BackStackRecord.java +++ b/core/java/android/app/BackStackRecord.java @@ -25,7 +25,6 @@ import android.text.TextUtils; import android.transition.Transition; import android.transition.TransitionManager; import android.transition.TransitionSet; -import android.transition.TransitionUtils; import android.util.ArrayMap; import android.util.Log; import android.util.LogWriter; diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 503657b..eb27830 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -16,17 +16,9 @@ package android.app; -import android.app.usage.IUsageStatsManager; -import android.app.usage.UsageStatsManager; -import android.appwidget.AppWidgetManager; -import android.os.Build; -import android.service.persistentdata.IPersistentDataBlockService; -import android.service.persistentdata.PersistentDataBlockManager; - -import com.android.internal.appwidget.IAppWidgetService; +import com.android.internal.annotations.GuardedBy; import com.android.internal.util.Preconditions; -import android.bluetooth.BluetoothManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentProvider; @@ -34,19 +26,15 @@ import android.content.ContentResolver; import android.content.Context; import android.content.ContextWrapper; import android.content.IContentProvider; +import android.content.IIntentReceiver; import android.content.Intent; import android.content.IntentFilter; -import android.content.IIntentReceiver; import android.content.IntentSender; -import android.content.IRestrictionsManager; import android.content.ReceiverCallNotAllowedException; -import android.content.RestrictionsManager; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; -import android.content.pm.ILauncherApps; import android.content.pm.IPackageManager; -import android.content.pm.LauncherApps; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.AssetManager; @@ -58,101 +46,28 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; -import android.hardware.ConsumerIrManager; -import android.hardware.ISerialManager; -import android.hardware.SerialManager; -import android.hardware.SystemSensorManager; -import android.hardware.hdmi.HdmiControlManager; -import android.hardware.hdmi.IHdmiControlService; -import android.hardware.camera2.CameraManager; import android.hardware.display.DisplayManager; -import android.hardware.input.InputManager; -import android.hardware.usb.IUsbManager; -import android.hardware.usb.UsbManager; -import android.location.CountryDetector; -import android.location.ICountryDetector; -import android.location.ILocationManager; -import android.location.LocationManager; -import android.media.AudioManager; -import android.media.MediaRouter; -import android.media.midi.IMidiManager; -import android.media.midi.MidiManager; -import android.media.projection.MediaProjectionManager; -import android.media.session.MediaSessionManager; -import android.media.tv.ITvInputManager; -import android.media.tv.TvInputManager; -import android.net.ConnectivityManager; -import android.net.IConnectivityManager; -import android.net.EthernetManager; -import android.net.IEthernetManager; -import android.net.INetworkPolicyManager; -import android.net.NetworkPolicyManager; -import android.net.NetworkScoreManager; import android.net.Uri; -import android.net.nsd.INsdManager; -import android.net.nsd.NsdManager; -import android.net.wifi.IWifiManager; -import android.net.wifi.WifiManager; -import android.net.wifi.passpoint.IWifiPasspointManager; -import android.net.wifi.passpoint.WifiPasspointManager; -import android.net.wifi.p2p.IWifiP2pManager; -import android.net.wifi.p2p.WifiP2pManager; -import android.net.wifi.IWifiScanner; -import android.net.wifi.WifiScanner; -import android.net.wifi.IRttManager; -import android.net.wifi.RttManager; -import android.nfc.NfcManager; -import android.os.BatteryManager; import android.os.Binder; +import android.os.Build; import android.os.Bundle; import android.os.Debug; -import android.os.DropBoxManager; import android.os.Environment; import android.os.FileUtils; import android.os.Handler; import android.os.IBinder; -import android.os.IPowerManager; -import android.os.IUserManager; import android.os.Looper; -import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; -import android.os.SystemVibrator; -import android.os.UserManager; import android.os.storage.IMountService; -import android.os.storage.StorageManager; -import android.print.IPrintManager; -import android.print.PrintManager; -import android.service.fingerprint.IFingerprintService; -import android.service.fingerprint.FingerprintManager; -import android.telecom.TelecomManager; -import android.telephony.SubscriptionManager; -import android.telephony.TelephonyManager; -import android.content.ClipboardManager; import android.util.AndroidRuntimeException; import android.util.ArrayMap; import android.util.Log; import android.util.Slog; -import android.view.DisplayAdjustments; -import android.view.ContextThemeWrapper; import android.view.Display; -import android.view.PhoneLayoutInflater; -import android.view.WindowManagerImpl; -import android.view.accessibility.AccessibilityManager; -import android.view.accessibility.CaptioningManager; -import android.view.inputmethod.InputMethodManager; -import android.view.textservice.TextServicesManager; -import android.accounts.AccountManager; -import android.accounts.IAccountManager; -import android.app.admin.DevicePolicyManager; -import android.app.job.IJobScheduler; -import android.app.trust.TrustManager; - -import com.android.internal.annotations.GuardedBy; -import com.android.internal.app.IAppOpsService; -import com.android.internal.os.IDropBoxManagerService; +import android.view.DisplayAdjustments; import java.io.File; import java.io.FileInputStream; @@ -160,8 +75,6 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; class ReceiverRestrictedContext extends ContextWrapper { ReceiverRestrictedContext(Context base) { @@ -270,521 +183,8 @@ class ContextImpl extends Context { private static final String[] EMPTY_FILE_LIST = {}; - /** - * Override this class when the system service constructor needs a - * ContextImpl. Else, use StaticServiceFetcher below. - */ - /*package*/ static class ServiceFetcher { - int mContextCacheIndex = -1; - - /** - * Main entrypoint; only override if you don't need caching. - */ - public Object getService(ContextImpl ctx) { - ArrayList<Object> cache = ctx.mServiceCache; - Object service; - synchronized (cache) { - if (cache.size() == 0) { - // Initialize the cache vector on first access. - // At this point sNextPerContextServiceCacheIndex - // is the number of potential services that are - // cached per-Context. - for (int i = 0; i < sNextPerContextServiceCacheIndex; i++) { - cache.add(null); - } - } else { - service = cache.get(mContextCacheIndex); - if (service != null) { - return service; - } - } - service = createService(ctx); - cache.set(mContextCacheIndex, service); - return service; - } - } - - /** - * Override this to create a new per-Context instance of the - * service. getService() will handle locking and caching. - */ - public Object createService(ContextImpl ctx) { - throw new RuntimeException("Not implemented"); - } - } - - /** - * Override this class for services to be cached process-wide. - */ - abstract static class StaticServiceFetcher extends ServiceFetcher { - private Object mCachedInstance; - - @Override - public final Object getService(ContextImpl unused) { - synchronized (StaticServiceFetcher.this) { - Object service = mCachedInstance; - if (service != null) { - return service; - } - return mCachedInstance = createStaticService(); - } - } - - public abstract Object createStaticService(); - } - - private static final HashMap<String, ServiceFetcher> SYSTEM_SERVICE_MAP = - new HashMap<String, ServiceFetcher>(); - - private static int sNextPerContextServiceCacheIndex = 0; - private static void registerService(String serviceName, ServiceFetcher fetcher) { - if (!(fetcher instanceof StaticServiceFetcher)) { - fetcher.mContextCacheIndex = sNextPerContextServiceCacheIndex++; - } - SYSTEM_SERVICE_MAP.put(serviceName, fetcher); - } - - // This one's defined separately and given a variable name so it - // can be re-used by getWallpaperManager(), avoiding a HashMap - // lookup. - private static ServiceFetcher WALLPAPER_FETCHER = new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new WallpaperManager(ctx.getOuterContext(), - ctx.mMainThread.getHandler()); - }}; - - static { - registerService(ACCESSIBILITY_SERVICE, new ServiceFetcher() { - public Object getService(ContextImpl ctx) { - return AccessibilityManager.getInstance(ctx); - }}); - - registerService(CAPTIONING_SERVICE, new ServiceFetcher() { - public Object getService(ContextImpl ctx) { - return new CaptioningManager(ctx); - }}); - - registerService(ACCOUNT_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(ACCOUNT_SERVICE); - IAccountManager service = IAccountManager.Stub.asInterface(b); - return new AccountManager(ctx, service); - }}); - - registerService(ACTIVITY_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new ActivityManager(ctx.getOuterContext(), ctx.mMainThread.getHandler()); - }}); - - registerService(ALARM_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(ALARM_SERVICE); - IAlarmManager service = IAlarmManager.Stub.asInterface(b); - return new AlarmManager(service, ctx); - }}); - - registerService(AUDIO_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new AudioManager(ctx); - }}); - - registerService(MEDIA_ROUTER_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new MediaRouter(ctx); - }}); - - registerService(BLUETOOTH_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new BluetoothManager(ctx); - }}); - - registerService(HDMI_CONTROL_SERVICE, new StaticServiceFetcher() { - public Object createStaticService() { - IBinder b = ServiceManager.getService(HDMI_CONTROL_SERVICE); - return new HdmiControlManager(IHdmiControlService.Stub.asInterface(b)); - }}); - - registerService(CLIPBOARD_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new ClipboardManager(ctx.getOuterContext(), - ctx.mMainThread.getHandler()); - }}); - - registerService(CONNECTIVITY_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE); - return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b)); - }}); - - registerService(COUNTRY_DETECTOR, new StaticServiceFetcher() { - public Object createStaticService() { - IBinder b = ServiceManager.getService(COUNTRY_DETECTOR); - return new CountryDetector(ICountryDetector.Stub.asInterface(b)); - }}); - - registerService(DEVICE_POLICY_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return DevicePolicyManager.create(ctx, ctx.mMainThread.getHandler()); - }}); - - registerService(DOWNLOAD_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new DownloadManager(ctx.getContentResolver(), ctx.getPackageName()); - }}); - - registerService(BATTERY_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new BatteryManager(); - }}); - - registerService(NFC_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new NfcManager(ctx); - }}); - - registerService(DROPBOX_SERVICE, new StaticServiceFetcher() { - public Object createStaticService() { - return createDropBoxManager(); - }}); - - registerService(INPUT_SERVICE, new StaticServiceFetcher() { - public Object createStaticService() { - return InputManager.getInstance(); - }}); - - registerService(DISPLAY_SERVICE, new ServiceFetcher() { - @Override - public Object createService(ContextImpl ctx) { - return new DisplayManager(ctx.getOuterContext()); - }}); - - registerService(INPUT_METHOD_SERVICE, new StaticServiceFetcher() { - public Object createStaticService() { - return InputMethodManager.getInstance(); - }}); - - registerService(TEXT_SERVICES_MANAGER_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return TextServicesManager.getInstance(); - }}); - - registerService(KEYGUARD_SERVICE, new ServiceFetcher() { - public Object getService(ContextImpl ctx) { - // TODO: why isn't this caching it? It wasn't - // before, so I'm preserving the old behavior and - // using getService(), instead of createService() - // which would do the caching. - return new KeyguardManager(); - }}); - - registerService(LAYOUT_INFLATER_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new PhoneLayoutInflater(ctx.getOuterContext()); - }}); - - registerService(LOCATION_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(LOCATION_SERVICE); - return new LocationManager(ctx, ILocationManager.Stub.asInterface(b)); - }}); - - registerService(NETWORK_POLICY_SERVICE, new ServiceFetcher() { - @Override - public Object createService(ContextImpl ctx) { - return new NetworkPolicyManager(INetworkPolicyManager.Stub.asInterface( - ServiceManager.getService(NETWORK_POLICY_SERVICE))); - } - }); - - registerService(NOTIFICATION_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - final Context outerContext = ctx.getOuterContext(); - return new NotificationManager( - new ContextThemeWrapper(outerContext, - Resources.selectSystemTheme(0, - outerContext.getApplicationInfo().targetSdkVersion, - com.android.internal.R.style.Theme_Dialog, - com.android.internal.R.style.Theme_Holo_Dialog, - com.android.internal.R.style.Theme_DeviceDefault_Dialog, - com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog)), - ctx.mMainThread.getHandler()); - }}); - - registerService(NSD_SERVICE, new ServiceFetcher() { - @Override - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(NSD_SERVICE); - INsdManager service = INsdManager.Stub.asInterface(b); - return new NsdManager(ctx.getOuterContext(), service); - }}); - - // Note: this was previously cached in a static variable, but - // constructed using mMainThread.getHandler(), so converting - // it to be a regular Context-cached service... - registerService(POWER_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(POWER_SERVICE); - IPowerManager service = IPowerManager.Stub.asInterface(b); - if (service == null) { - Log.wtf(TAG, "Failed to get power manager service."); - } - return new PowerManager(ctx.getOuterContext(), - service, ctx.mMainThread.getHandler()); - }}); - - registerService(SEARCH_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new SearchManager(ctx.getOuterContext(), - ctx.mMainThread.getHandler()); - }}); - - registerService(SENSOR_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new SystemSensorManager(ctx.getOuterContext(), - ctx.mMainThread.getHandler().getLooper()); - }}); - - registerService(STATUS_BAR_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new StatusBarManager(ctx.getOuterContext()); - }}); - - registerService(STORAGE_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - try { - return new StorageManager( - ctx.getContentResolver(), ctx.mMainThread.getHandler().getLooper()); - } catch (RemoteException rex) { - Log.e(TAG, "Failed to create StorageManager", rex); - return null; - } - }}); - - registerService(TELEPHONY_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new TelephonyManager(ctx.getOuterContext()); - }}); - - registerService(TELEPHONY_SUBSCRIPTION_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new SubscriptionManager(ctx.getOuterContext()); - }}); - - registerService(TELECOM_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new TelecomManager(ctx.getOuterContext()); - }}); - - registerService(UI_MODE_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new UiModeManager(); - }}); - - registerService(USB_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(USB_SERVICE); - return new UsbManager(ctx, IUsbManager.Stub.asInterface(b)); - }}); - - registerService(SERIAL_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(SERIAL_SERVICE); - return new SerialManager(ctx, ISerialManager.Stub.asInterface(b)); - }}); - - registerService(VIBRATOR_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new SystemVibrator(ctx); - }}); - - registerService(WALLPAPER_SERVICE, WALLPAPER_FETCHER); - - registerService(WIFI_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(WIFI_SERVICE); - IWifiManager service = IWifiManager.Stub.asInterface(b); - return new WifiManager(ctx.getOuterContext(), service); - }}); - - registerService(WIFI_PASSPOINT_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(WIFI_PASSPOINT_SERVICE); - IWifiPasspointManager service = IWifiPasspointManager.Stub.asInterface(b); - return new WifiPasspointManager(ctx.getOuterContext(), service); - }}); - - registerService(WIFI_P2P_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(WIFI_P2P_SERVICE); - IWifiP2pManager service = IWifiP2pManager.Stub.asInterface(b); - return new WifiP2pManager(service); - }}); - - registerService(WIFI_SCANNING_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(WIFI_SCANNING_SERVICE); - IWifiScanner service = IWifiScanner.Stub.asInterface(b); - return new WifiScanner(ctx.getOuterContext(), service); - }}); - - registerService(WIFI_RTT_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(WIFI_RTT_SERVICE); - IRttManager service = IRttManager.Stub.asInterface(b); - return new RttManager(ctx.getOuterContext(), service); - }}); - - registerService(ETHERNET_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(ETHERNET_SERVICE); - IEthernetManager service = IEthernetManager.Stub.asInterface(b); - return new EthernetManager(ctx.getOuterContext(), service); - }}); - - registerService(WINDOW_SERVICE, new ServiceFetcher() { - Display mDefaultDisplay; - public Object getService(ContextImpl ctx) { - Display display = ctx.mDisplay; - if (display == null) { - if (mDefaultDisplay == null) { - DisplayManager dm = (DisplayManager)ctx.getOuterContext(). - getSystemService(Context.DISPLAY_SERVICE); - mDefaultDisplay = dm.getDisplay(Display.DEFAULT_DISPLAY); - } - display = mDefaultDisplay; - } - return new WindowManagerImpl(display); - }}); - - registerService(USER_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(USER_SERVICE); - IUserManager service = IUserManager.Stub.asInterface(b); - return new UserManager(ctx, service); - }}); - - registerService(APP_OPS_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(APP_OPS_SERVICE); - IAppOpsService service = IAppOpsService.Stub.asInterface(b); - return new AppOpsManager(ctx, service); - }}); - - registerService(CAMERA_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new CameraManager(ctx); - } - }); - - registerService(LAUNCHER_APPS_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(LAUNCHER_APPS_SERVICE); - ILauncherApps service = ILauncherApps.Stub.asInterface(b); - return new LauncherApps(ctx, service); - } - }); - - registerService(RESTRICTIONS_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(RESTRICTIONS_SERVICE); - IRestrictionsManager service = IRestrictionsManager.Stub.asInterface(b); - return new RestrictionsManager(ctx, service); - } - }); - registerService(PRINT_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder iBinder = ServiceManager.getService(Context.PRINT_SERVICE); - IPrintManager service = IPrintManager.Stub.asInterface(iBinder); - return new PrintManager(ctx.getOuterContext(), service, UserHandle.myUserId(), - UserHandle.getAppId(Process.myUid())); - }}); - - registerService(CONSUMER_IR_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new ConsumerIrManager(ctx); - }}); - - registerService(MEDIA_SESSION_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new MediaSessionManager(ctx); - } - }); - - registerService(TRUST_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(TRUST_SERVICE); - return new TrustManager(b); - } - }); - - registerService(FINGERPRINT_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder binder = ServiceManager.getService(FINGERPRINT_SERVICE); - IFingerprintService service = IFingerprintService.Stub.asInterface(binder); - return new FingerprintManager(ctx.getOuterContext(), service); - } - }); - - registerService(TV_INPUT_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder iBinder = ServiceManager.getService(TV_INPUT_SERVICE); - ITvInputManager service = ITvInputManager.Stub.asInterface(iBinder); - return new TvInputManager(service, UserHandle.myUserId()); - } - }); - - registerService(NETWORK_SCORE_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new NetworkScoreManager(ctx); - } - }); - - registerService(USAGE_STATS_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder iBinder = ServiceManager.getService(USAGE_STATS_SERVICE); - IUsageStatsManager service = IUsageStatsManager.Stub.asInterface(iBinder); - return new UsageStatsManager(ctx.getOuterContext(), service); - } - }); - - registerService(JOB_SCHEDULER_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(JOB_SCHEDULER_SERVICE); - return new JobSchedulerImpl(IJobScheduler.Stub.asInterface(b)); - }}); - - registerService(PERSISTENT_DATA_BLOCK_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(PERSISTENT_DATA_BLOCK_SERVICE); - IPersistentDataBlockService persistentDataBlockService = - IPersistentDataBlockService.Stub.asInterface(b); - if (persistentDataBlockService != null) { - return new PersistentDataBlockManager(persistentDataBlockService); - } else { - // not supported - return null; - } - } - }); - - registerService(MEDIA_PROJECTION_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new MediaProjectionManager(ctx); - } - }); - - registerService(APPWIDGET_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(APPWIDGET_SERVICE); - return new AppWidgetManager(ctx, IAppWidgetService.Stub.asInterface(b)); - }}); - - registerService(MIDI_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(MIDI_SERVICE); - return new MidiManager(ctx, IMidiManager.Stub.asInterface(b)); - }}); - } + // The system service cache for the system services that are cached per-ContextImpl. + final Object[] mServiceCache = SystemServiceRegistry.createServiceCache(); static ContextImpl getImpl(Context context) { Context nextContext; @@ -795,11 +195,6 @@ class ContextImpl extends Context { return (ContextImpl)context; } - // The system service cache for the system services that are - // cached per-ContextImpl. Package-scoped to avoid accessor - // methods. - final ArrayList<Object> mServiceCache = new ArrayList<Object>(); - @Override public AssetManager getAssets() { return getResources().getAssets(); @@ -914,6 +309,7 @@ class ContextImpl extends Context { throw new RuntimeException("Not supported in system context"); } + @Override public File getSharedPrefsFile(String name) { return makeFilename(getPreferencesDir(), name + ".xml"); } @@ -1201,40 +597,51 @@ class ContextImpl extends Context { } @Override + @Deprecated public Drawable getWallpaper() { return getWallpaperManager().getDrawable(); } @Override + @Deprecated public Drawable peekWallpaper() { return getWallpaperManager().peekDrawable(); } @Override + @Deprecated public int getWallpaperDesiredMinimumWidth() { return getWallpaperManager().getDesiredMinimumWidth(); } @Override + @Deprecated public int getWallpaperDesiredMinimumHeight() { return getWallpaperManager().getDesiredMinimumHeight(); } @Override - public void setWallpaper(Bitmap bitmap) throws IOException { + @Deprecated + public void setWallpaper(Bitmap bitmap) throws IOException { getWallpaperManager().setBitmap(bitmap); } @Override + @Deprecated public void setWallpaper(InputStream data) throws IOException { getWallpaperManager().setStream(data); } @Override + @Deprecated public void clearWallpaper() throws IOException { getWallpaperManager().clear(); } + private WallpaperManager getWallpaperManager() { + return getSystemService(WallpaperManager.class); + } + @Override public void startActivity(Intent intent) { warnIfCallingFromSystemProcess(); @@ -1506,6 +913,7 @@ class ContextImpl extends Context { } @Override + @Deprecated public void sendStickyBroadcast(Intent intent) { warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); @@ -1520,6 +928,7 @@ class ContextImpl extends Context { } @Override + @Deprecated public void sendStickyOrderedBroadcast(Intent intent, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, @@ -1554,6 +963,7 @@ class ContextImpl extends Context { } @Override + @Deprecated public void removeStickyBroadcast(Intent intent) { String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); if (resolvedType != null) { @@ -1569,6 +979,7 @@ class ContextImpl extends Context { } @Override + @Deprecated public void sendStickyBroadcastAsUser(Intent intent, UserHandle user) { String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); try { @@ -1581,6 +992,7 @@ class ContextImpl extends Context { } @Override + @Deprecated public void sendStickyOrderedBroadcastAsUser(Intent intent, UserHandle user, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, @@ -1614,6 +1026,7 @@ class ContextImpl extends Context { } @Override + @Deprecated public void removeStickyBroadcastAsUser(Intent intent, UserHandle user) { String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); if (resolvedType != null) { @@ -1850,25 +1263,12 @@ class ContextImpl extends Context { @Override public Object getSystemService(String name) { - ServiceFetcher fetcher = SYSTEM_SERVICE_MAP.get(name); - return fetcher == null ? null : fetcher.getService(this); - } - - private WallpaperManager getWallpaperManager() { - return (WallpaperManager) WALLPAPER_FETCHER.getService(this); + return SystemServiceRegistry.getSystemService(this, name); } - /* package */ static DropBoxManager createDropBoxManager() { - IBinder b = ServiceManager.getService(DROPBOX_SERVICE); - IDropBoxManagerService service = IDropBoxManagerService.Stub.asInterface(b); - if (service == null) { - // Don't return a DropBoxManager that will NPE upon use. - // This also avoids caching a broken DropBoxManager in - // getDropBoxManager during early boot, before the - // DROPBOX_SERVICE is registered. - return null; - } - return new DropBoxManager(service); + @Override + public String getSystemServiceName(Class<?> serviceClass) { + return SystemServiceRegistry.getSystemServiceName(serviceClass); } @Override @@ -1937,6 +1337,7 @@ class ContextImpl extends Context { } } + @Override public void enforcePermission( String permission, int pid, int uid, String message) { enforce(permission, @@ -1946,6 +1347,7 @@ class ContextImpl extends Context { message); } + @Override public void enforceCallingPermission(String permission, String message) { enforce(permission, checkCallingPermission(permission), @@ -1954,6 +1356,7 @@ class ContextImpl extends Context { message); } + @Override public void enforceCallingOrSelfPermission( String permission, String message) { enforce(permission, @@ -2091,6 +1494,7 @@ class ContextImpl extends Context { } } + @Override public void enforceUriPermission( Uri uri, int pid, int uid, int modeFlags, String message) { enforceForUri( @@ -2098,6 +1502,7 @@ class ContextImpl extends Context { false, uid, uri, message); } + @Override public void enforceCallingUriPermission( Uri uri, int modeFlags, String message) { enforceForUri( @@ -2106,6 +1511,7 @@ class ContextImpl extends Context { Binder.getCallingUid(), uri, message); } + @Override public void enforceCallingOrSelfUriPermission( Uri uri, int modeFlags, String message) { enforceForUri( @@ -2114,6 +1520,7 @@ class ContextImpl extends Context { Binder.getCallingUid(), uri, message); } + @Override public void enforceUriPermission( Uri uri, String readPermission, String writePermission, int pid, int uid, int modeFlags, String message) { @@ -2209,6 +1616,14 @@ class ContextImpl extends Context { mUser, mRestricted, display, null); } + Display getDisplay() { + if (mDisplay != null) { + return mDisplay; + } + DisplayManager dm = getSystemService(DisplayManager.class); + return dm.getDisplay(Display.DEFAULT_DISPLAY); + } + private int getDisplayId() { return mDisplay != null ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY; } @@ -2243,6 +1658,7 @@ class ContextImpl extends Context { } /** {@hide} */ + @Override public int getUserId() { return mUser.getIdentifier(); } @@ -2368,6 +1784,7 @@ class ContextImpl extends Context { return mActivityToken; } + @SuppressWarnings("deprecation") static void setFilePermissionsFromMode(String name, int mode, int extraPermissions) { int perms = FileUtils.S_IRUSR|FileUtils.S_IWUSR diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java index 75ccb23..8abe223 100644 --- a/core/java/android/app/ResourcesManager.java +++ b/core/java/android/app/ResourcesManager.java @@ -30,8 +30,6 @@ import android.util.DisplayMetrics; import android.util.Pair; import android.util.Slog; import android.view.Display; -import android.view.DisplayAdjustments; - import java.lang.ref.WeakReference; import java.util.Locale; diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java new file mode 100644 index 0000000..993f416 --- /dev/null +++ b/core/java/android/app/SystemServiceRegistry.java @@ -0,0 +1,776 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.app; + +import com.android.internal.app.IAppOpsService; +import com.android.internal.appwidget.IAppWidgetService; +import com.android.internal.os.IDropBoxManagerService; + +import android.accounts.AccountManager; +import android.accounts.IAccountManager; +import android.app.admin.DevicePolicyManager; +import android.app.job.IJobScheduler; +import android.app.job.JobScheduler; +import android.app.trust.TrustManager; +import android.app.usage.IUsageStatsManager; +import android.app.usage.UsageStatsManager; +import android.appwidget.AppWidgetManager; +import android.bluetooth.BluetoothManager; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.IRestrictionsManager; +import android.content.RestrictionsManager; +import android.content.pm.ILauncherApps; +import android.content.pm.LauncherApps; +import android.content.res.Resources; +import android.hardware.ConsumerIrManager; +import android.hardware.ISerialManager; +import android.hardware.SensorManager; +import android.hardware.SerialManager; +import android.hardware.SystemSensorManager; +import android.hardware.camera2.CameraManager; +import android.hardware.display.DisplayManager; +import android.hardware.hdmi.HdmiControlManager; +import android.hardware.hdmi.IHdmiControlService; +import android.hardware.input.InputManager; +import android.hardware.usb.IUsbManager; +import android.hardware.usb.UsbManager; +import android.location.CountryDetector; +import android.location.ICountryDetector; +import android.location.ILocationManager; +import android.location.LocationManager; +import android.media.AudioManager; +import android.media.MediaRouter; +import android.media.midi.IMidiManager; +import android.media.midi.MidiManager; +import android.media.projection.MediaProjectionManager; +import android.media.session.MediaSessionManager; +import android.media.tv.ITvInputManager; +import android.media.tv.TvInputManager; +import android.net.ConnectivityManager; +import android.net.EthernetManager; +import android.net.IConnectivityManager; +import android.net.IEthernetManager; +import android.net.INetworkPolicyManager; +import android.net.NetworkPolicyManager; +import android.net.NetworkScoreManager; +import android.net.nsd.INsdManager; +import android.net.nsd.NsdManager; +import android.net.wifi.IRttManager; +import android.net.wifi.IWifiManager; +import android.net.wifi.IWifiScanner; +import android.net.wifi.RttManager; +import android.net.wifi.WifiManager; +import android.net.wifi.WifiScanner; +import android.net.wifi.p2p.IWifiP2pManager; +import android.net.wifi.p2p.WifiP2pManager; +import android.net.wifi.passpoint.IWifiPasspointManager; +import android.net.wifi.passpoint.WifiPasspointManager; +import android.nfc.NfcManager; +import android.os.BatteryManager; +import android.os.DropBoxManager; +import android.os.IBinder; +import android.os.IPowerManager; +import android.os.IUserManager; +import android.os.PowerManager; +import android.os.Process; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.os.SystemVibrator; +import android.os.UserHandle; +import android.os.UserManager; +import android.os.Vibrator; +import android.os.storage.StorageManager; +import android.print.IPrintManager; +import android.print.PrintManager; +import android.service.fingerprint.FingerprintManager; +import android.service.fingerprint.IFingerprintService; +import android.service.persistentdata.IPersistentDataBlockService; +import android.service.persistentdata.PersistentDataBlockManager; +import android.telecom.TelecomManager; +import android.telephony.SubscriptionManager; +import android.telephony.TelephonyManager; +import android.util.Log; +import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; +import android.view.PhoneLayoutInflater; +import android.view.WindowManager; +import android.view.WindowManagerImpl; +import android.view.accessibility.AccessibilityManager; +import android.view.accessibility.CaptioningManager; +import android.view.inputmethod.InputMethodManager; +import android.view.textservice.TextServicesManager; + +import java.util.HashMap; + +/** + * Manages all of the system services that can be returned by {@link Context#getSystemService}. + * Used by {@link ContextImpl}. + */ +final class SystemServiceRegistry { + private final static String TAG = "SystemServiceRegistry"; + + // Service registry information. + // This information is never changed once static initialization has completed. + private static final HashMap<Class<?>, String> SYSTEM_SERVICE_NAMES = + new HashMap<Class<?>, String>(); + private static final HashMap<String, ServiceFetcher<?>> SYSTEM_SERVICE_FETCHERS = + new HashMap<String, ServiceFetcher<?>>(); + private static int sServiceCacheSize; + + // Not instantiable. + private SystemServiceRegistry() { } + + static { + registerService(Context.ACCESSIBILITY_SERVICE, AccessibilityManager.class, + new CachedServiceFetcher<AccessibilityManager>() { + @Override + public AccessibilityManager createService(ContextImpl ctx) { + return AccessibilityManager.getInstance(ctx); + }}); + + registerService(Context.CAPTIONING_SERVICE, CaptioningManager.class, + new CachedServiceFetcher<CaptioningManager>() { + @Override + public CaptioningManager createService(ContextImpl ctx) { + return new CaptioningManager(ctx); + }}); + + registerService(Context.ACCOUNT_SERVICE, AccountManager.class, + new CachedServiceFetcher<AccountManager>() { + @Override + public AccountManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.ACCOUNT_SERVICE); + IAccountManager service = IAccountManager.Stub.asInterface(b); + return new AccountManager(ctx, service); + }}); + + registerService(Context.ACTIVITY_SERVICE, ActivityManager.class, + new CachedServiceFetcher<ActivityManager>() { + @Override + public ActivityManager createService(ContextImpl ctx) { + return new ActivityManager(ctx.getOuterContext(), ctx.mMainThread.getHandler()); + }}); + + registerService(Context.ALARM_SERVICE, AlarmManager.class, + new CachedServiceFetcher<AlarmManager>() { + @Override + public AlarmManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.ALARM_SERVICE); + IAlarmManager service = IAlarmManager.Stub.asInterface(b); + return new AlarmManager(service, ctx); + }}); + + registerService(Context.AUDIO_SERVICE, AudioManager.class, + new CachedServiceFetcher<AudioManager>() { + @Override + public AudioManager createService(ContextImpl ctx) { + return new AudioManager(ctx); + }}); + + registerService(Context.MEDIA_ROUTER_SERVICE, MediaRouter.class, + new CachedServiceFetcher<MediaRouter>() { + @Override + public MediaRouter createService(ContextImpl ctx) { + return new MediaRouter(ctx); + }}); + + registerService(Context.BLUETOOTH_SERVICE, BluetoothManager.class, + new CachedServiceFetcher<BluetoothManager>() { + @Override + public BluetoothManager createService(ContextImpl ctx) { + return new BluetoothManager(ctx); + }}); + + registerService(Context.HDMI_CONTROL_SERVICE, HdmiControlManager.class, + new StaticServiceFetcher<HdmiControlManager>() { + @Override + public HdmiControlManager createService() { + IBinder b = ServiceManager.getService(Context.HDMI_CONTROL_SERVICE); + return new HdmiControlManager(IHdmiControlService.Stub.asInterface(b)); + }}); + + registerService(Context.CLIPBOARD_SERVICE, ClipboardManager.class, + new CachedServiceFetcher<ClipboardManager>() { + @Override + public ClipboardManager createService(ContextImpl ctx) { + return new ClipboardManager(ctx.getOuterContext(), + ctx.mMainThread.getHandler()); + }}); + + // The clipboard service moved to a new package. If someone asks for the old + // interface by class then we want to redirect over to the new interface instead + // (which extends it). + SYSTEM_SERVICE_NAMES.put(android.text.ClipboardManager.class, Context.CLIPBOARD_SERVICE); + + registerService(Context.CONNECTIVITY_SERVICE, ConnectivityManager.class, + new StaticServiceFetcher<ConnectivityManager>() { + @Override + public ConnectivityManager createService() { + IBinder b = ServiceManager.getService(Context.CONNECTIVITY_SERVICE); + return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b)); + }}); + + registerService(Context.COUNTRY_DETECTOR, CountryDetector.class, + new StaticServiceFetcher<CountryDetector>() { + @Override + public CountryDetector createService() { + IBinder b = ServiceManager.getService(Context.COUNTRY_DETECTOR); + return new CountryDetector(ICountryDetector.Stub.asInterface(b)); + }}); + + registerService(Context.DEVICE_POLICY_SERVICE, DevicePolicyManager.class, + new CachedServiceFetcher<DevicePolicyManager>() { + @Override + public DevicePolicyManager createService(ContextImpl ctx) { + return DevicePolicyManager.create(ctx, ctx.mMainThread.getHandler()); + }}); + + registerService(Context.DOWNLOAD_SERVICE, DownloadManager.class, + new CachedServiceFetcher<DownloadManager>() { + @Override + public DownloadManager createService(ContextImpl ctx) { + return new DownloadManager(ctx.getContentResolver(), ctx.getPackageName()); + }}); + + registerService(Context.BATTERY_SERVICE, BatteryManager.class, + new StaticServiceFetcher<BatteryManager>() { + @Override + public BatteryManager createService() { + return new BatteryManager(); + }}); + + registerService(Context.NFC_SERVICE, NfcManager.class, + new CachedServiceFetcher<NfcManager>() { + @Override + public NfcManager createService(ContextImpl ctx) { + return new NfcManager(ctx); + }}); + + registerService(Context.DROPBOX_SERVICE, DropBoxManager.class, + new StaticServiceFetcher<DropBoxManager>() { + @Override + public DropBoxManager createService() { + IBinder b = ServiceManager.getService(Context.DROPBOX_SERVICE); + IDropBoxManagerService service = IDropBoxManagerService.Stub.asInterface(b); + if (service == null) { + // Don't return a DropBoxManager that will NPE upon use. + // This also avoids caching a broken DropBoxManager in + // getDropBoxManager during early boot, before the + // DROPBOX_SERVICE is registered. + return null; + } + return new DropBoxManager(service); + }}); + + registerService(Context.INPUT_SERVICE, InputManager.class, + new StaticServiceFetcher<InputManager>() { + @Override + public InputManager createService() { + return InputManager.getInstance(); + }}); + + registerService(Context.DISPLAY_SERVICE, DisplayManager.class, + new CachedServiceFetcher<DisplayManager>() { + @Override + public DisplayManager createService(ContextImpl ctx) { + return new DisplayManager(ctx.getOuterContext()); + }}); + + registerService(Context.INPUT_METHOD_SERVICE, InputMethodManager.class, + new StaticServiceFetcher<InputMethodManager>() { + @Override + public InputMethodManager createService() { + return InputMethodManager.getInstance(); + }}); + + registerService(Context.TEXT_SERVICES_MANAGER_SERVICE, TextServicesManager.class, + new StaticServiceFetcher<TextServicesManager>() { + @Override + public TextServicesManager createService() { + return TextServicesManager.getInstance(); + }}); + + registerService(Context.KEYGUARD_SERVICE, KeyguardManager.class, + new StaticServiceFetcher<KeyguardManager>() { + @Override + public KeyguardManager createService() { + return new KeyguardManager(); + }}); + + registerService(Context.LAYOUT_INFLATER_SERVICE, LayoutInflater.class, + new CachedServiceFetcher<LayoutInflater>() { + @Override + public LayoutInflater createService(ContextImpl ctx) { + return new PhoneLayoutInflater(ctx.getOuterContext()); + }}); + + registerService(Context.LOCATION_SERVICE, LocationManager.class, + new CachedServiceFetcher<LocationManager>() { + @Override + public LocationManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.LOCATION_SERVICE); + return new LocationManager(ctx, ILocationManager.Stub.asInterface(b)); + }}); + + registerService(Context.NETWORK_POLICY_SERVICE, NetworkPolicyManager.class, + new StaticServiceFetcher<NetworkPolicyManager>() { + @Override + public NetworkPolicyManager createService() { + return new NetworkPolicyManager(INetworkPolicyManager.Stub.asInterface( + ServiceManager.getService(Context.NETWORK_POLICY_SERVICE))); + }}); + + registerService(Context.NOTIFICATION_SERVICE, NotificationManager.class, + new CachedServiceFetcher<NotificationManager>() { + @Override + public NotificationManager createService(ContextImpl ctx) { + final Context outerContext = ctx.getOuterContext(); + return new NotificationManager( + new ContextThemeWrapper(outerContext, + Resources.selectSystemTheme(0, + outerContext.getApplicationInfo().targetSdkVersion, + com.android.internal.R.style.Theme_Dialog, + com.android.internal.R.style.Theme_Holo_Dialog, + com.android.internal.R.style.Theme_DeviceDefault_Dialog, + com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog)), + ctx.mMainThread.getHandler()); + }}); + + registerService(Context.NSD_SERVICE, NsdManager.class, + new CachedServiceFetcher<NsdManager>() { + @Override + public NsdManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.NSD_SERVICE); + INsdManager service = INsdManager.Stub.asInterface(b); + return new NsdManager(ctx.getOuterContext(), service); + }}); + + registerService(Context.POWER_SERVICE, PowerManager.class, + new CachedServiceFetcher<PowerManager>() { + @Override + public PowerManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.POWER_SERVICE); + IPowerManager service = IPowerManager.Stub.asInterface(b); + if (service == null) { + Log.wtf(TAG, "Failed to get power manager service."); + } + return new PowerManager(ctx.getOuterContext(), + service, ctx.mMainThread.getHandler()); + }}); + + registerService(Context.SEARCH_SERVICE, SearchManager.class, + new CachedServiceFetcher<SearchManager>() { + @Override + public SearchManager createService(ContextImpl ctx) { + return new SearchManager(ctx.getOuterContext(), + ctx.mMainThread.getHandler()); + }}); + + registerService(Context.SENSOR_SERVICE, SensorManager.class, + new CachedServiceFetcher<SensorManager>() { + @Override + public SensorManager createService(ContextImpl ctx) { + return new SystemSensorManager(ctx.getOuterContext(), + ctx.mMainThread.getHandler().getLooper()); + }}); + + registerService(Context.STATUS_BAR_SERVICE, StatusBarManager.class, + new CachedServiceFetcher<StatusBarManager>() { + @Override + public StatusBarManager createService(ContextImpl ctx) { + return new StatusBarManager(ctx.getOuterContext()); + }}); + + registerService(Context.STORAGE_SERVICE, StorageManager.class, + new CachedServiceFetcher<StorageManager>() { + @Override + public StorageManager createService(ContextImpl ctx) { + try { + return new StorageManager( + ctx.getContentResolver(), ctx.mMainThread.getHandler().getLooper()); + } catch (RemoteException rex) { + Log.e(TAG, "Failed to create StorageManager", rex); + return null; + } + }}); + + registerService(Context.TELEPHONY_SERVICE, TelephonyManager.class, + new CachedServiceFetcher<TelephonyManager>() { + @Override + public TelephonyManager createService(ContextImpl ctx) { + return new TelephonyManager(ctx.getOuterContext()); + }}); + + registerService(Context.TELEPHONY_SUBSCRIPTION_SERVICE, SubscriptionManager.class, + new CachedServiceFetcher<SubscriptionManager>() { + @Override + public SubscriptionManager createService(ContextImpl ctx) { + return new SubscriptionManager(ctx.getOuterContext()); + }}); + + registerService(Context.TELECOM_SERVICE, TelecomManager.class, + new CachedServiceFetcher<TelecomManager>() { + @Override + public TelecomManager createService(ContextImpl ctx) { + return new TelecomManager(ctx.getOuterContext()); + }}); + + registerService(Context.UI_MODE_SERVICE, UiModeManager.class, + new CachedServiceFetcher<UiModeManager>() { + @Override + public UiModeManager createService(ContextImpl ctx) { + return new UiModeManager(); + }}); + + registerService(Context.USB_SERVICE, UsbManager.class, + new CachedServiceFetcher<UsbManager>() { + @Override + public UsbManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.USB_SERVICE); + return new UsbManager(ctx, IUsbManager.Stub.asInterface(b)); + }}); + + registerService(Context.SERIAL_SERVICE, SerialManager.class, + new CachedServiceFetcher<SerialManager>() { + @Override + public SerialManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.SERIAL_SERVICE); + return new SerialManager(ctx, ISerialManager.Stub.asInterface(b)); + }}); + + registerService(Context.VIBRATOR_SERVICE, Vibrator.class, + new CachedServiceFetcher<Vibrator>() { + @Override + public Vibrator createService(ContextImpl ctx) { + return new SystemVibrator(ctx); + }}); + + registerService(Context.WALLPAPER_SERVICE, WallpaperManager.class, + new CachedServiceFetcher<WallpaperManager>() { + @Override + public WallpaperManager createService(ContextImpl ctx) { + return new WallpaperManager(ctx.getOuterContext(), + ctx.mMainThread.getHandler()); + }}); + + registerService(Context.WIFI_SERVICE, WifiManager.class, + new CachedServiceFetcher<WifiManager>() { + @Override + public WifiManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.WIFI_SERVICE); + IWifiManager service = IWifiManager.Stub.asInterface(b); + return new WifiManager(ctx.getOuterContext(), service); + }}); + + registerService(Context.WIFI_PASSPOINT_SERVICE, WifiPasspointManager.class, + new CachedServiceFetcher<WifiPasspointManager>() { + @Override + public WifiPasspointManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.WIFI_PASSPOINT_SERVICE); + IWifiPasspointManager service = IWifiPasspointManager.Stub.asInterface(b); + return new WifiPasspointManager(ctx.getOuterContext(), service); + }}); + + registerService(Context.WIFI_P2P_SERVICE, WifiP2pManager.class, + new StaticServiceFetcher<WifiP2pManager>() { + @Override + public WifiP2pManager createService() { + IBinder b = ServiceManager.getService(Context.WIFI_P2P_SERVICE); + IWifiP2pManager service = IWifiP2pManager.Stub.asInterface(b); + return new WifiP2pManager(service); + }}); + + registerService(Context.WIFI_SCANNING_SERVICE, WifiScanner.class, + new CachedServiceFetcher<WifiScanner>() { + @Override + public WifiScanner createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.WIFI_SCANNING_SERVICE); + IWifiScanner service = IWifiScanner.Stub.asInterface(b); + return new WifiScanner(ctx.getOuterContext(), service); + }}); + + registerService(Context.WIFI_RTT_SERVICE, RttManager.class, + new CachedServiceFetcher<RttManager>() { + @Override + public RttManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.WIFI_RTT_SERVICE); + IRttManager service = IRttManager.Stub.asInterface(b); + return new RttManager(ctx.getOuterContext(), service); + }}); + + registerService(Context.ETHERNET_SERVICE, EthernetManager.class, + new CachedServiceFetcher<EthernetManager>() { + @Override + public EthernetManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.ETHERNET_SERVICE); + IEthernetManager service = IEthernetManager.Stub.asInterface(b); + return new EthernetManager(ctx.getOuterContext(), service); + }}); + + registerService(Context.WINDOW_SERVICE, WindowManager.class, + new CachedServiceFetcher<WindowManager>() { + @Override + public WindowManager createService(ContextImpl ctx) { + return new WindowManagerImpl(ctx.getDisplay()); + }}); + + registerService(Context.USER_SERVICE, UserManager.class, + new CachedServiceFetcher<UserManager>() { + @Override + public UserManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.USER_SERVICE); + IUserManager service = IUserManager.Stub.asInterface(b); + return new UserManager(ctx, service); + }}); + + registerService(Context.APP_OPS_SERVICE, AppOpsManager.class, + new CachedServiceFetcher<AppOpsManager>() { + @Override + public AppOpsManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.APP_OPS_SERVICE); + IAppOpsService service = IAppOpsService.Stub.asInterface(b); + return new AppOpsManager(ctx, service); + }}); + + registerService(Context.CAMERA_SERVICE, CameraManager.class, + new CachedServiceFetcher<CameraManager>() { + @Override + public CameraManager createService(ContextImpl ctx) { + return new CameraManager(ctx); + }}); + + registerService(Context.LAUNCHER_APPS_SERVICE, LauncherApps.class, + new CachedServiceFetcher<LauncherApps>() { + @Override + public LauncherApps createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.LAUNCHER_APPS_SERVICE); + ILauncherApps service = ILauncherApps.Stub.asInterface(b); + return new LauncherApps(ctx, service); + }}); + + registerService(Context.RESTRICTIONS_SERVICE, RestrictionsManager.class, + new CachedServiceFetcher<RestrictionsManager>() { + @Override + public RestrictionsManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.RESTRICTIONS_SERVICE); + IRestrictionsManager service = IRestrictionsManager.Stub.asInterface(b); + return new RestrictionsManager(ctx, service); + }}); + + registerService(Context.PRINT_SERVICE, PrintManager.class, + new CachedServiceFetcher<PrintManager>() { + @Override + public PrintManager createService(ContextImpl ctx) { + IBinder iBinder = ServiceManager.getService(Context.PRINT_SERVICE); + IPrintManager service = IPrintManager.Stub.asInterface(iBinder); + return new PrintManager(ctx.getOuterContext(), service, UserHandle.myUserId(), + UserHandle.getAppId(Process.myUid())); + }}); + + registerService(Context.CONSUMER_IR_SERVICE, ConsumerIrManager.class, + new CachedServiceFetcher<ConsumerIrManager>() { + @Override + public ConsumerIrManager createService(ContextImpl ctx) { + return new ConsumerIrManager(ctx); + }}); + + registerService(Context.MEDIA_SESSION_SERVICE, MediaSessionManager.class, + new CachedServiceFetcher<MediaSessionManager>() { + @Override + public MediaSessionManager createService(ContextImpl ctx) { + return new MediaSessionManager(ctx); + }}); + + registerService(Context.TRUST_SERVICE, TrustManager.class, + new StaticServiceFetcher<TrustManager>() { + @Override + public TrustManager createService() { + IBinder b = ServiceManager.getService(Context.TRUST_SERVICE); + return new TrustManager(b); + }}); + + registerService(Context.FINGERPRINT_SERVICE, FingerprintManager.class, + new CachedServiceFetcher<FingerprintManager>() { + @Override + public FingerprintManager createService(ContextImpl ctx) { + IBinder binder = ServiceManager.getService(Context.FINGERPRINT_SERVICE); + IFingerprintService service = IFingerprintService.Stub.asInterface(binder); + return new FingerprintManager(ctx.getOuterContext(), service); + }}); + + registerService(Context.TV_INPUT_SERVICE, TvInputManager.class, + new StaticServiceFetcher<TvInputManager>() { + @Override + public TvInputManager createService() { + IBinder iBinder = ServiceManager.getService(Context.TV_INPUT_SERVICE); + ITvInputManager service = ITvInputManager.Stub.asInterface(iBinder); + return new TvInputManager(service, UserHandle.myUserId()); + }}); + + registerService(Context.NETWORK_SCORE_SERVICE, NetworkScoreManager.class, + new CachedServiceFetcher<NetworkScoreManager>() { + @Override + public NetworkScoreManager createService(ContextImpl ctx) { + return new NetworkScoreManager(ctx); + }}); + + registerService(Context.USAGE_STATS_SERVICE, UsageStatsManager.class, + new CachedServiceFetcher<UsageStatsManager>() { + @Override + public UsageStatsManager createService(ContextImpl ctx) { + IBinder iBinder = ServiceManager.getService(Context.USAGE_STATS_SERVICE); + IUsageStatsManager service = IUsageStatsManager.Stub.asInterface(iBinder); + return new UsageStatsManager(ctx.getOuterContext(), service); + }}); + + registerService(Context.JOB_SCHEDULER_SERVICE, JobScheduler.class, + new StaticServiceFetcher<JobScheduler>() { + @Override + public JobScheduler createService() { + IBinder b = ServiceManager.getService(Context.JOB_SCHEDULER_SERVICE); + return new JobSchedulerImpl(IJobScheduler.Stub.asInterface(b)); + }}); + + registerService(Context.PERSISTENT_DATA_BLOCK_SERVICE, PersistentDataBlockManager.class, + new StaticServiceFetcher<PersistentDataBlockManager>() { + @Override + public PersistentDataBlockManager createService() { + IBinder b = ServiceManager.getService(Context.PERSISTENT_DATA_BLOCK_SERVICE); + IPersistentDataBlockService persistentDataBlockService = + IPersistentDataBlockService.Stub.asInterface(b); + if (persistentDataBlockService != null) { + return new PersistentDataBlockManager(persistentDataBlockService); + } else { + // not supported + return null; + } + }}); + + registerService(Context.MEDIA_PROJECTION_SERVICE, MediaProjectionManager.class, + new CachedServiceFetcher<MediaProjectionManager>() { + @Override + public MediaProjectionManager createService(ContextImpl ctx) { + return new MediaProjectionManager(ctx); + }}); + + registerService(Context.APPWIDGET_SERVICE, AppWidgetManager.class, + new CachedServiceFetcher<AppWidgetManager>() { + @Override + public AppWidgetManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.APPWIDGET_SERVICE); + return new AppWidgetManager(ctx, IAppWidgetService.Stub.asInterface(b)); + }}); + + registerService(Context.MIDI_SERVICE, MidiManager.class, + new CachedServiceFetcher<MidiManager>() { + @Override + public MidiManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.MIDI_SERVICE); + return new MidiManager(ctx, IMidiManager.Stub.asInterface(b)); + }}); + } + + /** + * Creates an array which is used to cache per-Context service instances. + */ + public static Object[] createServiceCache() { + return new Object[sServiceCacheSize]; + } + + /** + * Gets a system service from a given context. + */ + public static Object getSystemService(ContextImpl ctx, String name) { + ServiceFetcher<?> fetcher = SYSTEM_SERVICE_FETCHERS.get(name); + return fetcher != null ? fetcher.getService(ctx) : null; + } + + /** + * Gets the name of the system-level service that is represented by the specified class. + */ + public static String getSystemServiceName(Class<?> serviceClass) { + return SYSTEM_SERVICE_NAMES.get(serviceClass); + } + + /** + * Statically registers a system service with the context. + * This method must be called during static initialization only. + */ + private static <T> void registerService(String serviceName, Class<T> serviceClass, + ServiceFetcher<T> serviceFetcher) { + SYSTEM_SERVICE_NAMES.put(serviceClass, serviceName); + SYSTEM_SERVICE_FETCHERS.put(serviceName, serviceFetcher); + } + + /** + * Base interface for classes that fetch services. + * These objects must only be created during static initialization. + */ + static abstract interface ServiceFetcher<T> { + T getService(ContextImpl ctx); + } + + /** + * Override this class when the system service constructor needs a + * ContextImpl and should be cached and retained by that context. + */ + static abstract class CachedServiceFetcher<T> implements ServiceFetcher<T> { + private final int mCacheIndex; + + public CachedServiceFetcher() { + mCacheIndex = sServiceCacheSize++; + } + + @Override + @SuppressWarnings("unchecked") + public final T getService(ContextImpl ctx) { + final Object[] cache = ctx.mServiceCache; + synchronized (cache) { + // Fetch or create the service. + Object service = cache[mCacheIndex]; + if (service == null) { + service = createService(ctx); + cache[mCacheIndex] = service; + } + return (T)service; + } + } + + public abstract T createService(ContextImpl ctx); + } + + /** + * Override this class when the system service does not need a ContextImpl + * and should be cached and retained process-wide. + */ + static abstract class StaticServiceFetcher<T> implements ServiceFetcher<T> { + private T mCachedInstance; + + @Override + public final T getService(ContextImpl unused) { + synchronized (StaticServiceFetcher.this) { + if (mCachedInstance == null) { + mCachedInstance = createService(); + } + return mCachedInstance; + } + } + + public abstract T createService(); + } +} diff --git a/core/java/android/app/TimePickerDialog.java b/core/java/android/app/TimePickerDialog.java index 3a2c21b..a3b3022 100644 --- a/core/java/android/app/TimePickerDialog.java +++ b/core/java/android/app/TimePickerDialog.java @@ -31,20 +31,21 @@ import android.widget.TimePicker.ValidationCallback; import com.android.internal.R; /** - * A dialog that prompts the user for the time of day using a {@link TimePicker}. + * A dialog that prompts the user for the time of day using a + * {@link TimePicker}. * - * <p>See the <a href="{@docRoot}guide/topics/ui/controls/pickers.html">Pickers</a> - * guide.</p> + * <p> + * See the <a href="{@docRoot}guide/topics/ui/controls/pickers.html">Pickers</a> + * guide. */ public class TimePickerDialog extends AlertDialog implements OnClickListener, OnTimeChangedListener { - private static final String HOUR = "hour"; private static final String MINUTE = "minute"; private static final String IS_24_HOUR = "is24hour"; private final TimePicker mTimePicker; - private final OnTimeSetListener mTimeSetCallback; + private final OnTimeSetListener mTimeSetListener; private final int mInitialHourOfDay; private final int mInitialMinute; @@ -52,59 +53,70 @@ public class TimePickerDialog extends AlertDialog implements OnClickListener, /** * The callback interface used to indicate the user is done filling in - * the time (they clicked on the 'Done' button). + * the time (e.g. they clicked on the 'OK' button). */ public interface OnTimeSetListener { - /** - * @param view The view associated with this listener. - * @param hourOfDay The hour that was set. - * @param minute The minute that was set. + * Called when the user is done setting a new time and the dialog has + * closed. + * + * @param view the view associated with this listener + * @param hourOfDay the hour that was set + * @param minute the minute that was set */ - void onTimeSet(TimePicker view, int hourOfDay, int minute); + public void onTimeSet(TimePicker view, int hourOfDay, int minute); } /** - * @param context Parent. - * @param callBack How parent is notified. - * @param hourOfDay The initial hour. - * @param minute The initial minute. - * @param is24HourView Whether this is a 24 hour view, or AM/PM. + * Creates a new time picker dialog. + * + * @param context the parent context + * @param listener the listener to call when the time is set + * @param hourOfDay the initial hour + * @param minute the initial minute + * @param is24HourView whether this is a 24 hour view or AM/PM */ - public TimePickerDialog(Context context, - OnTimeSetListener callBack, - int hourOfDay, int minute, boolean is24HourView) { - this(context, 0, callBack, hourOfDay, minute, is24HourView); + public TimePickerDialog(Context context, OnTimeSetListener listener, int hourOfDay, int minute, + boolean is24HourView) { + this(context, 0, listener, hourOfDay, minute, is24HourView); } - static int resolveDialogTheme(Context context, int resid) { - if (resid == 0) { + static int resolveDialogTheme(Context context, int resId) { + if (resId == 0) { final TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.timePickerDialogTheme, outValue, true); return outValue.resourceId; } else { - return resid; + return resId; } } /** - * @param context Parent. - * @param theme the theme to apply to this dialog - * @param callBack How parent is notified. - * @param hourOfDay The initial hour. - * @param minute The initial minute. + * Creates a new time picker dialog with the specified theme. + * + * @param context the parent context + * @param themeResId the resource ID of the theme to apply to this dialog + * @param listener the listener to call when the time is set + * @param hourOfDay the initial hour + * @param minute the initial minute * @param is24HourView Whether this is a 24 hour view, or AM/PM. */ - public TimePickerDialog(Context context, int theme, OnTimeSetListener callBack, int hourOfDay, - int minute, boolean is24HourView) { - super(context, resolveDialogTheme(context, theme)); + public TimePickerDialog(Context context, int themeResId, OnTimeSetListener listener, + int hourOfDay, int minute, boolean is24HourView) { + super(context, resolveDialogTheme(context, themeResId)); - mTimeSetCallback = callBack; + mTimeSetListener = listener; mInitialHourOfDay = hourOfDay; mInitialMinute = minute; mIs24HourView = is24HourView; final Context themeContext = getContext(); + + + final TypedValue outValue = new TypedValue(); + context.getTheme().resolveAttribute(R.attr.timePickerDialogTheme, outValue, true); + final int layoutResId = outValue.resourceId; + final LayoutInflater inflater = LayoutInflater.from(themeContext); final View view = inflater.inflate(R.layout.time_picker_dialog, null); setView(view); @@ -129,8 +141,8 @@ public class TimePickerDialog extends AlertDialog implements OnClickListener, public void onClick(DialogInterface dialog, int which) { switch (which) { case BUTTON_POSITIVE: - if (mTimeSetCallback != null) { - mTimeSetCallback.onTimeSet(mTimePicker, mTimePicker.getCurrentHour(), + if (mTimeSetListener != null) { + mTimeSetListener.onTimeSet(mTimePicker, mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute()); } break; diff --git a/core/java/android/app/VoiceInteractor.java b/core/java/android/app/VoiceInteractor.java index 7f9693f..7b84cb4 100644 --- a/core/java/android/app/VoiceInteractor.java +++ b/core/java/android/app/VoiceInteractor.java @@ -156,8 +156,8 @@ public class VoiceInteractor { @Override public void deliverCancel(IVoiceInteractorRequest request) throws RemoteException { - mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO( - MSG_CANCEL_RESULT, request)); + mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageOO( + MSG_CANCEL_RESULT, request, null)); } }; diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index dcbd669..badb606 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -188,7 +188,7 @@ public class WallpaperManager { } @Override - public void setColorFilter(ColorFilter cf) { + public void setColorFilter(ColorFilter colorFilter) { throw new UnsupportedOperationException("Not supported with this drawable"); } diff --git a/core/java/android/app/admin/DeviceAdminInfo.java b/core/java/android/app/admin/DeviceAdminInfo.java index 3074b49..d1e40ae 100644 --- a/core/java/android/app/admin/DeviceAdminInfo.java +++ b/core/java/android/app/admin/DeviceAdminInfo.java @@ -165,15 +165,24 @@ public final class DeviceAdminInfo implements Parcelable { /** @hide */ public static class PolicyInfo { public final int ident; - final public String tag; - final public int label; - final public int description; - - public PolicyInfo(int identIn, String tagIn, int labelIn, int descriptionIn) { - ident = identIn; - tag = tagIn; - label = labelIn; - description = descriptionIn; + public final String tag; + public final int label; + public final int description; + public final int labelForSecondaryUsers; + public final int descriptionForSecondaryUsers; + + public PolicyInfo(int ident, String tag, int label, int description) { + this(ident, tag, label, description, label, description); + } + + public PolicyInfo(int ident, String tag, int label, int description, + int labelForSecondaryUsers, int descriptionForSecondaryUsers) { + this.ident = ident; + this.tag = tag; + this.label = label; + this.description = description; + this.labelForSecondaryUsers = labelForSecondaryUsers; + this.descriptionForSecondaryUsers = descriptionForSecondaryUsers; } } @@ -184,7 +193,10 @@ public final class DeviceAdminInfo implements Parcelable { static { sPoliciesDisplayOrder.add(new PolicyInfo(USES_POLICY_WIPE_DATA, "wipe-data", com.android.internal.R.string.policylab_wipeData, - com.android.internal.R.string.policydesc_wipeData)); + com.android.internal.R.string.policydesc_wipeData, + com.android.internal.R.string.policylab_wipeData_secondaryUser, + com.android.internal.R.string.policydesc_wipeData_secondaryUser + )); sPoliciesDisplayOrder.add(new PolicyInfo(USES_POLICY_RESET_PASSWORD, "reset-password", com.android.internal.R.string.policylab_resetPassword, com.android.internal.R.string.policydesc_resetPassword)); @@ -193,7 +205,10 @@ public final class DeviceAdminInfo implements Parcelable { com.android.internal.R.string.policydesc_limitPassword)); sPoliciesDisplayOrder.add(new PolicyInfo(USES_POLICY_WATCH_LOGIN, "watch-login", com.android.internal.R.string.policylab_watchLogin, - com.android.internal.R.string.policydesc_watchLogin)); + com.android.internal.R.string.policydesc_watchLogin, + com.android.internal.R.string.policylab_watchLogin, + com.android.internal.R.string.policydesc_watchLogin_secondaryUser + )); sPoliciesDisplayOrder.add(new PolicyInfo(USES_POLICY_FORCE_LOCK, "force-lock", com.android.internal.R.string.policylab_forceLock, com.android.internal.R.string.policydesc_forceLock)); diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index d0ebdbd..6d5b4e0 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -41,7 +41,6 @@ import android.os.UserManager; import android.provider.Settings; import android.security.Credentials; import android.service.restrictions.RestrictionsReceiver; -import android.service.trust.TrustAgentService; import android.util.Log; import com.android.org.conscrypt.TrustedCertificateStore; @@ -68,7 +67,7 @@ import java.util.List; /** * Public interface for managing policies enforced on a device. Most clients of this class must be * registered with the system as a - * <a href={@docRoot}guide/topics/admin/device-admin.html">device administrator</a>. Additionally, + * <a href="{@docRoot}guide/topics/admin/device-admin.html">device administrator</a>. Additionally, * a device administrator may be registered as either a profile or device owner. A given method is * accessible to all device administrators unless the documentation for that method specifies that * it is restricted to either device or profile owners. @@ -2710,6 +2709,7 @@ public class DevicePolicyManager { * <p>If {@link #KEYGUARD_DISABLE_TRUST_AGENTS} is set and options is not null for all admins, * then it's up to the TrustAgent itself to aggregate the values from all device admins. * <p>Consult documentation for the specific TrustAgent to determine legal options parameters. + * @hide */ public void setTrustAgentConfiguration(ComponentName admin, ComponentName target, PersistableBundle configuration) { @@ -2735,6 +2735,7 @@ public class DevicePolicyManager { * for this {@param agent} or calls it with a null configuration, null is returned. * @param agent Which component to get enabled features for. * @return configuration for the given trust agent. + * @hide */ public List<PersistableBundle> getTrustAgentConfiguration(ComponentName admin, ComponentName agent) { @@ -3305,7 +3306,8 @@ public class DevicePolicyManager { * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * * @see Activity#startLockTask() - * @see DeviceAdminReceiver#onLockTaskModeChanged(Context, Intent, boolean, String) + * @see DeviceAdminReceiver#onLockTaskModeEntering(Context, Intent, String) + * @see DeviceAdminReceiver#onLockTaskModeExiting(Context, Intent) * @see UserManager#DISALLOW_CREATE_WINDOWS */ public void setLockTaskPackages(ComponentName admin, String[] packages) @@ -3360,13 +3362,18 @@ public class DevicePolicyManager { * <li>{@link Settings.Global#ADB_ENABLED}</li> * <li>{@link Settings.Global#AUTO_TIME}</li> * <li>{@link Settings.Global#AUTO_TIME_ZONE}</li> - * <li>{@link Settings.Global#BLUETOOTH_ON}</li> + * <li>{@link Settings.Global#BLUETOOTH_ON} + * Changing this setting has not effect as of {@link android.os.Build.VERSION_CODES#MNC}. Use + * {@link android.bluetooth.BluetoothAdapter#enable()} and + * {@link android.bluetooth.BluetoothAdapter#disable()} instead.</li> * <li>{@link Settings.Global#DATA_ROAMING}</li> * <li>{@link Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}</li> * <li>{@link Settings.Global#MODE_RINGER}</li> * <li>{@link Settings.Global#NETWORK_PREFERENCE}</li> * <li>{@link Settings.Global#USB_MASS_STORAGE_ENABLED}</li> - * <li>{@link Settings.Global#WIFI_ON}</li> + * <li>{@link Settings.Global#WIFI_ON} + * Changing this setting has not effect as of {@link android.os.Build.VERSION_CODES#MNC}. Use + * {@link android.net.wifi.WifiManager#setWifiEnabled(boolean)} instead.</li> * <li>{@link Settings.Global#WIFI_SLEEP_POLICY}</li> * </ul> * diff --git a/core/java/android/app/backup/BackupDataOutput.java b/core/java/android/app/backup/BackupDataOutput.java index 048a4bb..1fe63e7 100644 --- a/core/java/android/app/backup/BackupDataOutput.java +++ b/core/java/android/app/backup/BackupDataOutput.java @@ -18,8 +18,6 @@ package android.app.backup; import android.annotation.SystemApi; import android.os.ParcelFileDescriptor; -import android.os.Process; - import java.io.FileDescriptor; import java.io.IOException; diff --git a/core/java/android/app/job/JobParameters.java b/core/java/android/app/job/JobParameters.java index 62734f2..7ee39f5 100644 --- a/core/java/android/app/job/JobParameters.java +++ b/core/java/android/app/job/JobParameters.java @@ -17,7 +17,6 @@ package android.app.job; import android.app.job.IJobCallback; -import android.app.job.IJobCallback.Stub; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; diff --git a/core/java/android/app/job/JobScheduler.java b/core/java/android/app/job/JobScheduler.java index 89efeb2..a1c11f3 100644 --- a/core/java/android/app/job/JobScheduler.java +++ b/core/java/android/app/job/JobScheduler.java @@ -18,8 +18,6 @@ package android.app.job; import java.util.List; -import android.content.Context; - /** * This is an API for scheduling various types of jobs against the framework that will be executed * in your application's own process. diff --git a/core/java/android/app/usage/UsageEvents.java b/core/java/android/app/usage/UsageEvents.java index 3cf3c95..58279d7 100644 --- a/core/java/android/app/usage/UsageEvents.java +++ b/core/java/android/app/usage/UsageEvents.java @@ -68,6 +68,11 @@ public final class UsageEvents implements Parcelable { public static final int CONFIGURATION_CHANGE = 5; /** + * An event type denoting that a package was interacted with in some way. + */ + public static final int INTERACTION = 6; + + /** * {@hide} */ public String mPackage; diff --git a/core/java/android/app/usage/UsageStatsManagerInternal.java b/core/java/android/app/usage/UsageStatsManagerInternal.java index 083a48a..0122069 100644 --- a/core/java/android/app/usage/UsageStatsManagerInternal.java +++ b/core/java/android/app/usage/UsageStatsManagerInternal.java @@ -37,6 +37,16 @@ public abstract class UsageStatsManagerInternal { public abstract void reportEvent(ComponentName component, int userId, int eventType); /** + * Reports an event to the UsageStatsManager. + * + * @param packageName The package for which this event occurred. + * @param userId The user id to which the component belongs to. + * @param eventType The event that occurred. Valid values can be found at + * {@link UsageEvents} + */ + public abstract void reportEvent(String packageName, int userId, int eventType); + + /** * Reports a configuration change to the UsageStatsManager. * * @param config The new device configuration. diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java index 022e225..3219fe7 100644 --- a/core/java/android/appwidget/AppWidgetHostView.java +++ b/core/java/android/appwidget/AppWidgetHostView.java @@ -31,9 +31,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; -import android.os.Process; import android.os.SystemClock; -import android.os.UserHandle; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index b8f4bf8..be26eac 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -26,9 +26,7 @@ import android.bluetooth.le.ScanRecord; import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; import android.content.Context; -import android.os.Handler; import android.os.IBinder; -import android.os.Looper; import android.os.ParcelUuid; import android.os.RemoteException; import android.os.ServiceManager; @@ -36,7 +34,6 @@ import android.util.Log; import android.util.Pair; import java.io.IOException; -import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; diff --git a/core/java/android/bluetooth/le/TruncatedFilter.java b/core/java/android/bluetooth/le/TruncatedFilter.java index 6a6b3e3..685b174 100644 --- a/core/java/android/bluetooth/le/TruncatedFilter.java +++ b/core/java/android/bluetooth/le/TruncatedFilter.java @@ -17,9 +17,6 @@ package android.bluetooth.le; import android.annotation.SystemApi; -import android.os.Parcel; -import android.os.Parcelable; - import java.util.List; /** diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java index 0cff4c0..393cf8e 100644 --- a/core/java/android/content/ContentProvider.java +++ b/core/java/android/content/ContentProvider.java @@ -19,6 +19,7 @@ package android.content; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.Manifest.permission.INTERACT_ACROSS_USERS; +import android.annotation.Nullable; import android.app.AppOpsManager; import android.content.pm.PathPermission; import android.content.pm.ProviderInfo; @@ -364,7 +365,8 @@ public abstract class ContentProvider implements ComponentCallbacks2 { } @Override - public Bundle call(String callingPkg, String method, String arg, Bundle extras) { + public Bundle call( + String callingPkg, String method, @Nullable String arg, @Nullable Bundle extras) { final String original = setCallingPackage(callingPkg); try { return ContentProvider.this.call(method, arg, extras); @@ -1742,7 +1744,7 @@ public abstract class ContentProvider implements ComponentCallbacks2 { * @return provider-defined return value. May be {@code null}, which is also * the default for providers which don't implement any call methods. */ - public Bundle call(String method, String arg, Bundle extras) { + public Bundle call(String method, @Nullable String arg, @Nullable Bundle extras) { return null; } diff --git a/core/java/android/content/ContentProviderResult.java b/core/java/android/content/ContentProviderResult.java index ec3d002..4196f27 100644 --- a/core/java/android/content/ContentProviderResult.java +++ b/core/java/android/content/ContentProviderResult.java @@ -18,7 +18,6 @@ package android.content; import android.content.ContentProvider; import android.net.Uri; -import android.os.UserHandle; import android.os.Parcelable; import android.os.Parcel; diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java index a09fee9..17a8eb7 100644 --- a/core/java/android/content/ContentResolver.java +++ b/core/java/android/content/ContentResolver.java @@ -17,6 +17,7 @@ package android.content; import android.accounts.Account; +import android.annotation.Nullable; import android.app.ActivityManagerNative; import android.app.ActivityThread; import android.app.AppGlobals; @@ -1357,7 +1358,8 @@ public abstract class ContentResolver { * @throws NullPointerException if uri or method is null * @throws IllegalArgumentException if uri is not known */ - public final Bundle call(Uri uri, String method, String arg, Bundle extras) { + public final Bundle call( + Uri uri, String method, @Nullable String arg, @Nullable Bundle extras) { if (uri == null) { throw new NullPointerException("uri == null"); } diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 46ccc95..010c860 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -36,7 +36,6 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; -import android.media.MediaScannerConnection.OnScanCompletedListener; import android.net.Uri; import android.os.Bundle; import android.os.Environment; @@ -469,10 +468,10 @@ public abstract class Context { /** * Retrieve styled attribute information in this Context's theme. See - * {@link Resources.Theme#obtainStyledAttributes(int[])} + * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int[])} * for more information. * - * @see Resources.Theme#obtainStyledAttributes(int[]) + * @see android.content.res.Resources.Theme#obtainStyledAttributes(int[]) */ public final TypedArray obtainStyledAttributes( int[] attrs) { @@ -481,10 +480,10 @@ public abstract class Context { /** * Retrieve styled attribute information in this Context's theme. See - * {@link Resources.Theme#obtainStyledAttributes(int, int[])} + * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])} * for more information. * - * @see Resources.Theme#obtainStyledAttributes(int, int[]) + * @see android.content.res.Resources.Theme#obtainStyledAttributes(int, int[]) */ public final TypedArray obtainStyledAttributes( @StyleableRes int resid, int[] attrs) throws Resources.NotFoundException { @@ -493,10 +492,10 @@ public abstract class Context { /** * Retrieve styled attribute information in this Context's theme. See - * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} + * {@link android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} * for more information. * - * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) + * @see android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) */ public final TypedArray obtainStyledAttributes( AttributeSet set, int[] attrs) { @@ -505,10 +504,10 @@ public abstract class Context { /** * Retrieve styled attribute information in this Context's theme. See - * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} + * {@link android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} * for more information. * - * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) + * @see android.content.res.Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) */ public final TypedArray obtainStyledAttributes( AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { @@ -753,7 +752,8 @@ public abstract class Context { * are not automatically scanned by the media scanner, you can explicitly * add them to the media database with * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], - * OnScanCompletedListener) MediaScannerConnection.scanFile}. + * android.media.MediaScannerConnection.OnScanCompletedListener) + * MediaScannerConnection.scanFile}. * Note that this is not the same as * {@link android.os.Environment#getExternalStoragePublicDirectory * Environment.getExternalStoragePublicDirectory()}, which provides @@ -1918,7 +1918,7 @@ public abstract class Context { * @return The first sticky intent found that matches <var>filter</var>, * or null if there are none. * - * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler + * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) * @see #sendBroadcast * @see #unregisterReceiver */ @@ -2081,7 +2081,9 @@ public abstract class Context { * @hide */ @SystemApi - public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, UserHandle user) { + @SuppressWarnings("unused") + public boolean bindServiceAsUser(Intent service, ServiceConnection conn, + int flags, UserHandle user) { throw new RuntimeException("Not implemented. Must override in a subclass."); } @@ -2316,6 +2318,51 @@ public abstract class Context { public abstract Object getSystemService(@ServiceName @NonNull String name); /** + * Return the handle to a system-level service by class. + * <p> + * Currently available classes are: + * {@link android.view.WindowManager}, {@link android.view.LayoutInflater}, + * {@link android.app.ActivityManager}, {@link android.os.PowerManager}, + * {@link android.app.AlarmManager}, {@link android.app.NotificationManager}, + * {@link android.app.KeyguardManager}, {@link android.location.LocationManager}, + * {@link android.app.SearchManager}, {@link android.os.Vibrator}, + * {@link android.net.ConnectivityManager}, + * {@link android.net.wifi.WifiManager}, + * {@link android.media.AudioManager}, {@link android.media.MediaRouter}, + * {@link android.telephony.TelephonyManager}, {@link android.telephony.SubscriptionManager}, + * {@link android.view.inputmethod.InputMethodManager}, + * {@link android.app.UiModeManager}, {@link android.app.DownloadManager}, + * {@link android.os.BatteryManager}, {@link android.app.job.JobScheduler}. + * </p><p> + * Note: System services obtained via this API may be closely associated with + * the Context in which they are obtained from. In general, do not share the + * service objects between various different contexts (Activities, Applications, + * Services, Providers, etc.) + * </p> + * + * @param serviceClass The class of the desired service. + * @return The service or null if the class is not a supported system service. + */ + @SuppressWarnings("unchecked") + public final <T> T getSystemService(Class<T> serviceClass) { + // Because subclasses may override getSystemService(String) we cannot + // perform a lookup by class alone. We must first map the class to its + // service name then invoke the string-based method. + String serviceName = getSystemServiceName(serviceClass); + return serviceName != null ? (T)getSystemService(serviceName) : null; + } + + /** + * Gets the name of the system-level service that is represented by the specified class. + * + * @param serviceClass The class of the desired service. + * @return The service name or null if the class is not a supported system service. + * + * @hide + */ + public abstract String getSystemServiceName(Class<?> serviceClass); + + /** * Use with {@link #getSystemService} to retrieve a * {@link android.os.PowerManager} for controlling power management, * including "wake locks," which let you keep the device on while @@ -2610,7 +2657,7 @@ public abstract class Context { * of fingerprints. * * @see #getSystemService - * @see android.app.FingerprintManager + * @see android.service.fingerprint.FingerprintManager * @hide */ public static final String FINGERPRINT_SERVICE = "fingerprint"; @@ -2666,11 +2713,11 @@ public abstract class Context { /** * Use with {@link #getSystemService} to retrieve a - * {@link android.text.ClipboardManager} for accessing and modifying + * {@link android.content.ClipboardManager} for accessing and modifying * the contents of the global clipboard. * * @see #getSystemService - * @see android.text.ClipboardManager + * @see android.content.ClipboardManager */ public static final String CLIPBOARD_SERVICE = "clipboard"; @@ -2965,7 +3012,7 @@ public abstract class Context { * android.media.projection.MediaProjectionManager} instance for managing * media projection sessions. * @see #getSystemService - * @see android.media.projection.ProjectionManager + * @see android.media.projection.MediaProjectionManager */ public static final String MEDIA_PROJECTION_SERVICE = "media_projection"; @@ -3401,7 +3448,7 @@ public abstract class Context { * are not shared, however they share common state (Resources, ClassLoader, * etc) so the Context instance itself is fairly lightweight. * - * <p>Throws {@link PackageManager.NameNotFoundException} if there is no + * <p>Throws {@link android.content.pm.PackageManager.NameNotFoundException} if there is no * application with the given package name. * * <p>Throws {@link java.lang.SecurityException} if the Context requested diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java index cfae1cf..6e8b7c1 100644 --- a/core/java/android/content/ContextWrapper.java +++ b/core/java/android/content/ContextWrapper.java @@ -284,36 +284,43 @@ public class ContextWrapper extends Context { } @Override + @Deprecated public Drawable getWallpaper() { return mBase.getWallpaper(); } @Override + @Deprecated public Drawable peekWallpaper() { return mBase.peekWallpaper(); } @Override + @Deprecated public int getWallpaperDesiredMinimumWidth() { return mBase.getWallpaperDesiredMinimumWidth(); } @Override + @Deprecated public int getWallpaperDesiredMinimumHeight() { return mBase.getWallpaperDesiredMinimumHeight(); } @Override + @Deprecated public void setWallpaper(Bitmap bitmap) throws IOException { mBase.setWallpaper(bitmap); } @Override + @Deprecated public void setWallpaper(InputStream data) throws IOException { mBase.setWallpaper(data); } @Override + @Deprecated public void clearWallpaper() throws IOException { mBase.clearWallpaper(); } @@ -445,11 +452,13 @@ public class ContextWrapper extends Context { } @Override + @Deprecated public void sendStickyBroadcast(Intent intent) { mBase.sendStickyBroadcast(intent); } @Override + @Deprecated public void sendStickyOrderedBroadcast( Intent intent, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, @@ -460,16 +469,19 @@ public class ContextWrapper extends Context { } @Override + @Deprecated public void removeStickyBroadcast(Intent intent) { mBase.removeStickyBroadcast(intent); } @Override + @Deprecated public void sendStickyBroadcastAsUser(Intent intent, UserHandle user) { mBase.sendStickyBroadcastAsUser(intent, user); } @Override + @Deprecated public void sendStickyOrderedBroadcastAsUser(Intent intent, UserHandle user, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, @@ -479,6 +491,7 @@ public class ContextWrapper extends Context { } @Override + @Deprecated public void removeStickyBroadcastAsUser(Intent intent, UserHandle user) { mBase.removeStickyBroadcastAsUser(intent, user); } @@ -563,6 +576,11 @@ public class ContextWrapper extends Context { } @Override + public String getSystemServiceName(Class<?> serviceClass) { + return mBase.getSystemServiceName(serviceClass); + } + + @Override public int checkPermission(String permission, int pid, int uid) { return mBase.checkPermission(permission, pid, uid); } @@ -679,6 +697,7 @@ public class ContextWrapper extends Context { } /** @hide */ + @Override public Context createApplicationContext(ApplicationInfo application, int flags) throws PackageManager.NameNotFoundException { return mBase.createApplicationContext(application, flags); diff --git a/core/java/android/content/IContentProvider.java b/core/java/android/content/IContentProvider.java index f858406..4afe38b 100644 --- a/core/java/android/content/IContentProvider.java +++ b/core/java/android/content/IContentProvider.java @@ -16,6 +16,7 @@ package android.content; +import android.annotation.Nullable; import android.content.res.AssetFileDescriptor; import android.database.Cursor; import android.net.Uri; @@ -56,7 +57,8 @@ public interface IContentProvider extends IInterface { public ContentProviderResult[] applyBatch(String callingPkg, ArrayList<ContentProviderOperation> operations) throws RemoteException, OperationApplicationException; - public Bundle call(String callingPkg, String method, String arg, Bundle extras) + public Bundle call( + String callingPkg, String method, @Nullable String arg, @Nullable Bundle extras) throws RemoteException; public ICancellationSignal createCancellationSignal() throws RemoteException; diff --git a/core/java/android/content/UndoManager.java b/core/java/android/content/UndoManager.java index e3bc238..1d5ed8a 100644 --- a/core/java/android/content/UndoManager.java +++ b/core/java/android/content/UndoManager.java @@ -105,8 +105,7 @@ public class UndoManager { return owner; } - owner = new UndoOwner(tag); - owner.mManager = this; + owner = new UndoOwner(tag, this); owner.mData = data; mOwners.put(tag, owner); return owner; @@ -116,7 +115,6 @@ public class UndoManager { // XXX need to figure out how to prune. if (false) { mOwners.remove(owner.mTag); - owner.mManager = null; } } @@ -164,6 +162,7 @@ public class UndoManager { owner.mSavedIdx = mNextSavedIdx; out.writeInt(owner.mSavedIdx); out.writeString(owner.mTag); + out.writeInt(owner.mOpCount); mNextSavedIdx++; } } @@ -202,7 +201,9 @@ public class UndoManager { UndoOwner owner = mStateOwners[idx]; if (owner == null) { String tag = in.readString(); - owner = new UndoOwner(tag); + int opCount = in.readInt(); + owner = new UndoOwner(tag, this); + owner.mOpCount = opCount; mStateOwners[idx] = owner; mOwners.put(tag, owner); } diff --git a/core/java/android/content/UndoOwner.java b/core/java/android/content/UndoOwner.java index d0cdc95..fd257ab 100644 --- a/core/java/android/content/UndoOwner.java +++ b/core/java/android/content/UndoOwner.java @@ -23,8 +23,8 @@ package android.content; */ public class UndoOwner { final String mTag; + final UndoManager mManager; - UndoManager mManager; Object mData; int mOpCount; @@ -32,8 +32,15 @@ public class UndoOwner { int mStateSeq; int mSavedIdx; - UndoOwner(String tag) { + UndoOwner(String tag, UndoManager manager) { + if (tag == null) { + throw new NullPointerException("tag can't be null"); + } + if (manager == null) { + throw new NullPointerException("manager can't be null"); + } mTag = tag; + mManager = manager; } /** @@ -54,4 +61,15 @@ public class UndoOwner { public Object getData() { return mData; } + + @Override + public String toString() { + return "UndoOwner:[mTag=" + mTag + + " mManager=" + mManager + + " mData=" + mData + + " mData=" + mData + + " mOpCount=" + mOpCount + + " mStateSeq=" + mStateSeq + + " mSavedIdx=" + mSavedIdx + "]"; + } } diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java index e822708..e1a2aa9 100644 --- a/core/java/android/content/pm/ApplicationInfo.java +++ b/core/java/android/content/pm/ApplicationInfo.java @@ -881,6 +881,13 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { /** * @hide */ + public boolean isForwardLocked() { + return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0; + } + + /** + * @hide + */ @Override protected ApplicationInfo getApplicationInfo() { return this; } diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index c164340..c81517a 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -16,7 +16,6 @@ package android.content.pm; -import android.app.AppGlobals; import android.content.ComponentName; import android.content.Context; import android.content.Intent; diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index b0e0300..1140756 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -4405,6 +4405,13 @@ public class PackageParser { return false; } + /** + * @hide + */ + public boolean isForwardLocked() { + return applicationInfo.isForwardLocked(); + } + public String toString() { return "Package{" + Integer.toHexString(System.identityHashCode(this)) diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java index b42d8bc..ace402a 100644 --- a/core/java/android/content/res/ColorStateList.java +++ b/core/java/android/content/res/ColorStateList.java @@ -462,46 +462,6 @@ public class ColorStateList implements Parcelable { return mColors; } - /** - * If the color state list does not already have an entry matching the - * specified state, prepends a state set and color pair to a color state - * list. - * <p> - * This is a workaround used in TimePicker and DatePicker until we can - * add support for theme attributes in ColorStateList. - * - * @param colorStateList the source color state list - * @param state the state to prepend - * @param color the color to use for the given state - * @return a new color state list, or the source color state list if there - * was already a matching state set - * - * @hide Remove when we can support theme attributes. - */ - public static ColorStateList addFirstIfMissing( - ColorStateList colorStateList, int state, int color) { - final int[][] inputStates = colorStateList.getStates(); - for (int i = 0; i < inputStates.length; i++) { - final int[] inputState = inputStates[i]; - for (int j = 0; j < inputState.length; j++) { - if (inputState[j] == state) { - return colorStateList; - } - } - } - - final int[][] outputStates = new int[inputStates.length + 1][]; - System.arraycopy(inputStates, 0, outputStates, 1, inputStates.length); - outputStates[0] = new int[] { state }; - - final int[] inputColors = colorStateList.getColors(); - final int[] outputColors = new int[inputColors.length + 1]; - System.arraycopy(inputColors, 0, outputColors, 1, inputColors.length); - outputColors[0] = color; - - return new ColorStateList(outputStates, outputColors); - } - @Override public String toString() { return "ColorStateList{" + diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 3e922f2..584f3f6 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -47,7 +47,6 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable.ConstantState; import android.os.Build; import android.os.Bundle; -import android.os.IBinder; import android.os.Trace; import android.util.ArrayMap; import android.util.AttributeSet; diff --git a/core/java/android/content/res/TypedArray.java b/core/java/android/content/res/TypedArray.java index 3d43304..3e07f0c 100644 --- a/core/java/android/content/res/TypedArray.java +++ b/core/java/android/content/res/TypedArray.java @@ -22,7 +22,6 @@ import android.graphics.drawable.Drawable; import android.os.StrictMode; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.util.Log; import android.util.TypedValue; import com.android.internal.util.XmlUtils; diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index 310ab76..49f6513 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -44,7 +44,6 @@ import android.view.SurfaceHolder; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java index bec9489..0ef0a29 100644 --- a/core/java/android/hardware/camera2/CameraDevice.java +++ b/core/java/android/hardware/camera2/CameraDevice.java @@ -17,7 +17,6 @@ package android.hardware.camera2; import android.hardware.camera2.params.StreamConfigurationMap; -import android.graphics.ImageFormat; import android.os.Handler; import android.view.Surface; diff --git a/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java index 5bc7f71..e87a2f8 100644 --- a/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java +++ b/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java @@ -21,11 +21,9 @@ import android.hardware.camera2.CameraDevice; import android.hardware.camera2.CaptureRequest; import android.hardware.camera2.dispatch.ArgumentReplacingDispatcher; import android.hardware.camera2.dispatch.BroadcastDispatcher; -import android.hardware.camera2.dispatch.Dispatchable; import android.hardware.camera2.dispatch.DuckTypingDispatcher; import android.hardware.camera2.dispatch.HandlerDispatcher; import android.hardware.camera2.dispatch.InvokeDispatcher; -import android.hardware.camera2.dispatch.NullDispatcher; import android.hardware.camera2.utils.TaskDrainer; import android.hardware.camera2.utils.TaskSingleDrainer; import android.os.Handler; diff --git a/core/java/android/hardware/camera2/legacy/BurstHolder.java b/core/java/android/hardware/camera2/legacy/BurstHolder.java index b9c89f8..e7b3682 100644 --- a/core/java/android/hardware/camera2/legacy/BurstHolder.java +++ b/core/java/android/hardware/camera2/legacy/BurstHolder.java @@ -17,10 +17,6 @@ package android.hardware.camera2.legacy; import android.hardware.camera2.CaptureRequest; -import android.hardware.camera2.impl.CameraMetadataNative; -import android.util.Log; -import android.view.Surface; - import java.util.ArrayList; import java.util.Collection; import java.util.List; diff --git a/core/java/android/hardware/camera2/legacy/LegacyFaceDetectMapper.java b/core/java/android/hardware/camera2/legacy/LegacyFaceDetectMapper.java index 6215a8f..e576beb 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyFaceDetectMapper.java +++ b/core/java/android/hardware/camera2/legacy/LegacyFaceDetectMapper.java @@ -33,7 +33,6 @@ import android.util.Size; import com.android.internal.util.ArrayUtils; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import static android.hardware.camera2.CaptureRequest.*; diff --git a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java index 802b938..8776418 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java +++ b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java @@ -42,7 +42,6 @@ import android.util.SizeF; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Comparator; import java.util.List; import static com.android.internal.util.Preconditions.*; diff --git a/core/java/android/hardware/camera2/legacy/LegacyRequestMapper.java b/core/java/android/hardware/camera2/legacy/LegacyRequestMapper.java index 61f7b8b..3688610 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyRequestMapper.java +++ b/core/java/android/hardware/camera2/legacy/LegacyRequestMapper.java @@ -34,7 +34,6 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; -import static com.android.internal.util.Preconditions.*; import static android.hardware.camera2.CaptureRequest.*; /** diff --git a/core/java/android/hardware/camera2/legacy/ParameterUtils.java b/core/java/android/hardware/camera2/legacy/ParameterUtils.java index 3b10eb5..9e9a6fe 100644 --- a/core/java/android/hardware/camera2/legacy/ParameterUtils.java +++ b/core/java/android/hardware/camera2/legacy/ParameterUtils.java @@ -22,8 +22,6 @@ import android.graphics.Rect; import android.graphics.RectF; import android.hardware.Camera; import android.hardware.Camera.Area; -import android.hardware.camera2.legacy.ParameterUtils.MeteringData; -import android.hardware.camera2.legacy.ParameterUtils.ZoomData; import android.hardware.camera2.params.Face; import android.hardware.camera2.params.MeteringRectangle; import android.hardware.camera2.utils.ListUtils; diff --git a/core/java/android/hardware/camera2/legacy/PerfMeasurement.java b/core/java/android/hardware/camera2/legacy/PerfMeasurement.java index b930ec2..53278c7 100644 --- a/core/java/android/hardware/camera2/legacy/PerfMeasurement.java +++ b/core/java/android/hardware/camera2/legacy/PerfMeasurement.java @@ -20,7 +20,6 @@ import android.os.SystemClock; import android.util.Log; import java.io.BufferedWriter; -import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; diff --git a/core/java/android/hardware/camera2/legacy/RequestHolder.java b/core/java/android/hardware/camera2/legacy/RequestHolder.java index edd8e4e..9b628fb 100644 --- a/core/java/android/hardware/camera2/legacy/RequestHolder.java +++ b/core/java/android/hardware/camera2/legacy/RequestHolder.java @@ -17,7 +17,6 @@ package android.hardware.camera2.legacy; import android.hardware.camera2.CaptureRequest; -import android.hardware.camera2.impl.CameraMetadataNative; import android.util.Log; import android.view.Surface; diff --git a/core/java/android/hardware/camera2/legacy/RequestThreadManager.java b/core/java/android/hardware/camera2/legacy/RequestThreadManager.java index cf3510d..ff74c59 100644 --- a/core/java/android/hardware/camera2/legacy/RequestThreadManager.java +++ b/core/java/android/hardware/camera2/legacy/RequestThreadManager.java @@ -16,13 +16,11 @@ package android.hardware.camera2.legacy; -import android.graphics.ImageFormat; import android.graphics.SurfaceTexture; import android.hardware.Camera; import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CaptureRequest; import android.hardware.camera2.impl.CameraDeviceImpl; -import android.hardware.camera2.params.StreamConfigurationMap; import android.hardware.camera2.utils.LongParcelable; import android.hardware.camera2.utils.SizeAreaComparator; import android.hardware.camera2.impl.CameraMetadataNative; @@ -38,7 +36,6 @@ import android.view.Surface; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; diff --git a/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableArray.java b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableArray.java index 22b87ef..d89518b 100644 --- a/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableArray.java +++ b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableArray.java @@ -25,9 +25,6 @@ import java.lang.reflect.Array; import java.nio.ByteBuffer; import java.util.ArrayList; -import static android.hardware.camera2.impl.CameraMetadataNative.*; -import static android.hardware.camera2.marshal.MarshalHelpers.*; - /** * Marshal any array {@code T}. * diff --git a/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableParcelable.java b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableParcelable.java index 1fd6a1d..0b7a4bf 100644 --- a/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableParcelable.java +++ b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableParcelable.java @@ -25,9 +25,6 @@ import android.util.Log; import java.lang.reflect.Field; import java.nio.ByteBuffer; -import static android.hardware.camera2.impl.CameraMetadataNative.*; -import static android.hardware.camera2.marshal.MarshalHelpers.*; - /** * Marshal any {@code T extends Parcelable} to/from any native type * diff --git a/core/java/android/hardware/camera2/marshal/impl/MarshalQueryablePrimitive.java b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryablePrimitive.java index 189b597..090dd48 100644 --- a/core/java/android/hardware/camera2/marshal/impl/MarshalQueryablePrimitive.java +++ b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryablePrimitive.java @@ -23,8 +23,6 @@ import android.util.Rational; import static android.hardware.camera2.impl.CameraMetadataNative.*; import static android.hardware.camera2.marshal.MarshalHelpers.*; -import static com.android.internal.util.Preconditions.*; - import java.nio.ByteBuffer; /** diff --git a/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableRange.java b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableRange.java index 8512804..64763e7 100644 --- a/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableRange.java +++ b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableRange.java @@ -27,9 +27,6 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.nio.ByteBuffer; -import static android.hardware.camera2.impl.CameraMetadataNative.*; -import static android.hardware.camera2.marshal.MarshalHelpers.*; - /** * Marshal {@link Range} to/from any native type */ diff --git a/core/java/android/hardware/camera2/params/LensShadingMap.java b/core/java/android/hardware/camera2/params/LensShadingMap.java index 13929b1..d6b84f2 100644 --- a/core/java/android/hardware/camera2/params/LensShadingMap.java +++ b/core/java/android/hardware/camera2/params/LensShadingMap.java @@ -19,7 +19,6 @@ package android.hardware.camera2.params; import static com.android.internal.util.Preconditions.*; import static android.hardware.camera2.params.RggbChannelVector.*; -import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CaptureResult; import android.hardware.camera2.utils.HashCodeHelpers; diff --git a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java index 479c842..f5304f8 100644 --- a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java +++ b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java @@ -26,7 +26,6 @@ import android.hardware.camera2.legacy.LegacyCameraDevice; import android.hardware.camera2.legacy.LegacyMetadataMapper; import android.hardware.camera2.legacy.LegacyExceptionUtils.BufferQueueAbandonedException; import android.view.Surface; -import android.util.Log; import android.util.Range; import android.util.Size; diff --git a/core/java/android/hardware/display/DisplayManagerInternal.java b/core/java/android/hardware/display/DisplayManagerInternal.java index bb162153..adab9be 100644 --- a/core/java/android/hardware/display/DisplayManagerInternal.java +++ b/core/java/android/hardware/display/DisplayManagerInternal.java @@ -132,6 +132,19 @@ public abstract class DisplayManagerInternal { float requestedRefreshRate, boolean inTraversal); /** + * Applies an offset to the contents of a display, for example to avoid burn-in. + * <p> + * TODO: Technically this should be associated with a physical rather than logical + * display but this is good enough for now. + * </p> + * + * @param displayId The logical display id to update. + * @param x The X offset by which to shift the contents of the display. + * @param y The Y offset by which to shift the contents of the display. + */ + public abstract void setDisplayOffsets(int displayId, int x, int y); + + /** * Describes the requested power state of the display. * * This object is intended to describe the general characteristics of the diff --git a/core/java/android/hardware/display/VirtualDisplay.java b/core/java/android/hardware/display/VirtualDisplay.java index 4ddf10f..d354666 100644 --- a/core/java/android/hardware/display/VirtualDisplay.java +++ b/core/java/android/hardware/display/VirtualDisplay.java @@ -15,7 +15,6 @@ */ package android.hardware.display; -import android.os.IBinder; import android.view.Display; import android.view.Surface; diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index e5995b0..444f020 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -27,8 +27,6 @@ import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; -import android.os.Parcel; -import android.os.Parcelable; import android.os.RemoteException; import android.os.ServiceManager; import android.os.Vibrator; diff --git a/core/java/android/hardware/soundtrigger/SoundTriggerModule.java b/core/java/android/hardware/soundtrigger/SoundTriggerModule.java index 1a8723d..e23a2bb 100644 --- a/core/java/android/hardware/soundtrigger/SoundTriggerModule.java +++ b/core/java/android/hardware/soundtrigger/SoundTriggerModule.java @@ -16,13 +16,10 @@ package android.hardware.soundtrigger; -import android.content.Context; -import android.content.Intent; import android.os.Handler; import android.os.Looper; import android.os.Message; import java.lang.ref.WeakReference; -import java.util.UUID; /** * The SoundTriggerModule provides APIs to control sound models and sound detection diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 808be21..5f49d99 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -25,7 +25,6 @@ import android.content.Intent; import android.net.NetworkUtils; import android.os.Binder; import android.os.Build.VERSION_CODES; -import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; @@ -38,7 +37,6 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.telephony.SubscriptionManager; -import android.telephony.TelephonyManager; import android.util.ArrayMap; import android.util.Log; diff --git a/core/java/android/net/DhcpResults.java b/core/java/android/net/DhcpResults.java index 6159e1e..87c063f 100644 --- a/core/java/android/net/DhcpResults.java +++ b/core/java/android/net/DhcpResults.java @@ -17,7 +17,6 @@ package android.net; import android.net.NetworkUtils; -import android.os.Parcelable; import android.os.Parcel; import android.text.TextUtils; import android.util.Log; diff --git a/core/java/android/net/Network.java b/core/java/android/net/Network.java index dfe2413..ab57c9b 100644 --- a/core/java/android/net/Network.java +++ b/core/java/android/net/Network.java @@ -26,7 +26,6 @@ import java.net.DatagramSocket; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.MalformedURLException; -import java.net.ProxySelector; import java.net.Socket; import java.net.SocketAddress; import java.net.SocketException; diff --git a/core/java/android/net/NetworkAgent.java b/core/java/android/net/NetworkAgent.java index 74d4ac2..24aaf0d 100644 --- a/core/java/android/net/NetworkAgent.java +++ b/core/java/android/net/NetworkAgent.java @@ -21,15 +21,12 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Messenger; -import android.os.Parcel; -import android.os.Parcelable; import android.util.Log; import com.android.internal.util.AsyncChannel; import com.android.internal.util.Protocol; import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; /** * A Utility class for handling for communicating between bearer-specific diff --git a/core/java/android/net/NetworkFactory.java b/core/java/android/net/NetworkFactory.java index 64d0fcf..e47220b 100644 --- a/core/java/android/net/NetworkFactory.java +++ b/core/java/android/net/NetworkFactory.java @@ -21,12 +21,9 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Messenger; -import android.os.Parcel; -import android.os.Parcelable; import android.util.Log; import android.util.SparseArray; -import com.android.internal.util.AsyncChannel; import com.android.internal.util.Protocol; /** diff --git a/core/java/android/net/NetworkRequest.java b/core/java/android/net/NetworkRequest.java index 5a09b46..7838b47 100644 --- a/core/java/android/net/NetworkRequest.java +++ b/core/java/android/net/NetworkRequest.java @@ -19,8 +19,6 @@ package android.net; import android.os.Parcel; import android.os.Parcelable; -import java.util.concurrent.atomic.AtomicInteger; - /** * Defines a request for a network, made through {@link NetworkRequest.Builder} and used * to request a network via {@link ConnectivityManager#requestNetwork} or listen for changes diff --git a/core/java/android/net/ProxyDataTracker.java b/core/java/android/net/ProxyDataTracker.java index 7d23125..54b732f 100644 --- a/core/java/android/net/ProxyDataTracker.java +++ b/core/java/android/net/ProxyDataTracker.java @@ -17,18 +17,14 @@ package android.net; import android.content.BroadcastReceiver; -import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.ServiceConnection; import android.os.Bundle; import android.os.Handler; -import android.os.IBinder; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; -import android.os.UserHandle; import android.util.Log; import java.net.InetAddress; diff --git a/core/java/android/net/StaticIpConfiguration.java b/core/java/android/net/StaticIpConfiguration.java index 37ee961..7f1b179 100644 --- a/core/java/android/net/StaticIpConfiguration.java +++ b/core/java/android/net/StaticIpConfiguration.java @@ -21,7 +21,6 @@ import android.os.Parcelable; import android.os.Parcel; import java.net.InetAddress; -import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import java.util.Objects; diff --git a/core/java/android/net/http/X509TrustManagerExtensions.java b/core/java/android/net/http/X509TrustManagerExtensions.java index bb36c20..eb4ceda 100644 --- a/core/java/android/net/http/X509TrustManagerExtensions.java +++ b/core/java/android/net/http/X509TrustManagerExtensions.java @@ -22,8 +22,6 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.List; -import javax.net.ssl.SSLParameters; -import javax.net.ssl.SSLSocket; import javax.net.ssl.X509TrustManager; /** diff --git a/core/java/android/os/BaseBundle.java b/core/java/android/os/BaseBundle.java index 1b02141..7f8c95b 100644 --- a/core/java/android/os/BaseBundle.java +++ b/core/java/android/os/BaseBundle.java @@ -16,6 +16,7 @@ package android.os; +import android.annotation.Nullable; import android.util.ArrayMap; import android.util.Log; @@ -63,7 +64,7 @@ public class BaseBundle { * inside of the Bundle. * @param capacity Initial size of the ArrayMap. */ - BaseBundle(ClassLoader loader, int capacity) { + BaseBundle(@Nullable ClassLoader loader, int capacity) { mMap = capacity > 0 ? new ArrayMap<String, Object>(capacity) : new ArrayMap<String, Object>(); mClassLoader = loader == null ? getClass().getClassLoader() : loader; @@ -276,6 +277,7 @@ public class BaseBundle { * @param key a String key * @return an Object, or null */ + @Nullable public Object get(String key) { unparcel(); return mMap.get(key); @@ -327,9 +329,9 @@ public class BaseBundle { * any existing value for the given key. Either key or value may be null. * * @param key a String, or null - * @param value a Boolean, or null + * @param value a boolean */ - public void putBoolean(String key, boolean value) { + public void putBoolean(@Nullable String key, boolean value) { unparcel(); mMap.put(key, value); } @@ -341,7 +343,7 @@ public class BaseBundle { * @param key a String, or null * @param value a byte */ - void putByte(String key, byte value) { + void putByte(@Nullable String key, byte value) { unparcel(); mMap.put(key, value); } @@ -351,9 +353,9 @@ public class BaseBundle { * any existing value for the given key. * * @param key a String, or null - * @param value a char, or null + * @param value a char */ - void putChar(String key, char value) { + void putChar(@Nullable String key, char value) { unparcel(); mMap.put(key, value); } @@ -365,7 +367,7 @@ public class BaseBundle { * @param key a String, or null * @param value a short */ - void putShort(String key, short value) { + void putShort(@Nullable String key, short value) { unparcel(); mMap.put(key, value); } @@ -375,9 +377,9 @@ public class BaseBundle { * any existing value for the given key. * * @param key a String, or null - * @param value an int, or null + * @param value an int */ - public void putInt(String key, int value) { + public void putInt(@Nullable String key, int value) { unparcel(); mMap.put(key, value); } @@ -389,7 +391,7 @@ public class BaseBundle { * @param key a String, or null * @param value a long */ - public void putLong(String key, long value) { + public void putLong(@Nullable String key, long value) { unparcel(); mMap.put(key, value); } @@ -401,7 +403,7 @@ public class BaseBundle { * @param key a String, or null * @param value a float */ - void putFloat(String key, float value) { + void putFloat(@Nullable String key, float value) { unparcel(); mMap.put(key, value); } @@ -413,7 +415,7 @@ public class BaseBundle { * @param key a String, or null * @param value a double */ - public void putDouble(String key, double value) { + public void putDouble(@Nullable String key, double value) { unparcel(); mMap.put(key, value); } @@ -425,7 +427,7 @@ public class BaseBundle { * @param key a String, or null * @param value a String, or null */ - public void putString(String key, String value) { + public void putString(@Nullable String key, @Nullable String value) { unparcel(); mMap.put(key, value); } @@ -437,7 +439,7 @@ public class BaseBundle { * @param key a String, or null * @param value a CharSequence, or null */ - void putCharSequence(String key, CharSequence value) { + void putCharSequence(@Nullable String key, @Nullable CharSequence value) { unparcel(); mMap.put(key, value); } @@ -449,7 +451,7 @@ public class BaseBundle { * @param key a String, or null * @param value an ArrayList<Integer> object, or null */ - void putIntegerArrayList(String key, ArrayList<Integer> value) { + void putIntegerArrayList(@Nullable String key, @Nullable ArrayList<Integer> value) { unparcel(); mMap.put(key, value); } @@ -461,7 +463,7 @@ public class BaseBundle { * @param key a String, or null * @param value an ArrayList<String> object, or null */ - void putStringArrayList(String key, ArrayList<String> value) { + void putStringArrayList(@Nullable String key, @Nullable ArrayList<String> value) { unparcel(); mMap.put(key, value); } @@ -473,7 +475,7 @@ public class BaseBundle { * @param key a String, or null * @param value an ArrayList<CharSequence> object, or null */ - void putCharSequenceArrayList(String key, ArrayList<CharSequence> value) { + void putCharSequenceArrayList(@Nullable String key, @Nullable ArrayList<CharSequence> value) { unparcel(); mMap.put(key, value); } @@ -485,7 +487,7 @@ public class BaseBundle { * @param key a String, or null * @param value a Serializable object, or null */ - void putSerializable(String key, Serializable value) { + void putSerializable(@Nullable String key, @Nullable Serializable value) { unparcel(); mMap.put(key, value); } @@ -497,7 +499,7 @@ public class BaseBundle { * @param key a String, or null * @param value a boolean array object, or null */ - public void putBooleanArray(String key, boolean[] value) { + public void putBooleanArray(@Nullable String key, @Nullable boolean[] value) { unparcel(); mMap.put(key, value); } @@ -509,7 +511,7 @@ public class BaseBundle { * @param key a String, or null * @param value a byte array object, or null */ - void putByteArray(String key, byte[] value) { + void putByteArray(@Nullable String key, @Nullable byte[] value) { unparcel(); mMap.put(key, value); } @@ -521,7 +523,7 @@ public class BaseBundle { * @param key a String, or null * @param value a short array object, or null */ - void putShortArray(String key, short[] value) { + void putShortArray(@Nullable String key, @Nullable short[] value) { unparcel(); mMap.put(key, value); } @@ -533,7 +535,7 @@ public class BaseBundle { * @param key a String, or null * @param value a char array object, or null */ - void putCharArray(String key, char[] value) { + void putCharArray(@Nullable String key, @Nullable char[] value) { unparcel(); mMap.put(key, value); } @@ -545,7 +547,7 @@ public class BaseBundle { * @param key a String, or null * @param value an int array object, or null */ - public void putIntArray(String key, int[] value) { + public void putIntArray(@Nullable String key, @Nullable int[] value) { unparcel(); mMap.put(key, value); } @@ -557,7 +559,7 @@ public class BaseBundle { * @param key a String, or null * @param value a long array object, or null */ - public void putLongArray(String key, long[] value) { + public void putLongArray(@Nullable String key, @Nullable long[] value) { unparcel(); mMap.put(key, value); } @@ -569,7 +571,7 @@ public class BaseBundle { * @param key a String, or null * @param value a float array object, or null */ - void putFloatArray(String key, float[] value) { + void putFloatArray(@Nullable String key, @Nullable float[] value) { unparcel(); mMap.put(key, value); } @@ -581,7 +583,7 @@ public class BaseBundle { * @param key a String, or null * @param value a double array object, or null */ - public void putDoubleArray(String key, double[] value) { + public void putDoubleArray(@Nullable String key, @Nullable double[] value) { unparcel(); mMap.put(key, value); } @@ -593,7 +595,7 @@ public class BaseBundle { * @param key a String, or null * @param value a String array object, or null */ - public void putStringArray(String key, String[] value) { + public void putStringArray(@Nullable String key, @Nullable String[] value) { unparcel(); mMap.put(key, value); } @@ -605,7 +607,7 @@ public class BaseBundle { * @param key a String, or null * @param value a CharSequence array object, or null */ - void putCharSequenceArray(String key, CharSequence[] value) { + void putCharSequenceArray(@Nullable String key, @Nullable CharSequence[] value) { unparcel(); mMap.put(key, value); } @@ -914,7 +916,8 @@ public class BaseBundle { * @param key a String, or null * @return a String value, or null */ - public String getString(String key) { + @Nullable + public String getString(@Nullable String key) { unparcel(); final Object o = mMap.get(key); try { @@ -936,7 +939,7 @@ public class BaseBundle { * @return the String value associated with the given key, or defaultValue * if no valid String object is currently mapped to that key. */ - public String getString(String key, String defaultValue) { + public String getString(@Nullable String key, String defaultValue) { final String s = getString(key); return (s == null) ? defaultValue : s; } @@ -949,7 +952,8 @@ public class BaseBundle { * @param key a String, or null * @return a CharSequence value, or null */ - CharSequence getCharSequence(String key) { + @Nullable + CharSequence getCharSequence(@Nullable String key) { unparcel(); final Object o = mMap.get(key); try { @@ -971,7 +975,7 @@ public class BaseBundle { * @return the CharSequence value associated with the given key, or defaultValue * if no valid CharSequence object is currently mapped to that key. */ - CharSequence getCharSequence(String key, CharSequence defaultValue) { + CharSequence getCharSequence(@Nullable String key, CharSequence defaultValue) { final CharSequence cs = getCharSequence(key); return (cs == null) ? defaultValue : cs; } @@ -984,7 +988,8 @@ public class BaseBundle { * @param key a String, or null * @return a Serializable value, or null */ - Serializable getSerializable(String key) { + @Nullable + Serializable getSerializable(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1006,7 +1011,8 @@ public class BaseBundle { * @param key a String, or null * @return an ArrayList<String> value, or null */ - ArrayList<Integer> getIntegerArrayList(String key) { + @Nullable + ArrayList<Integer> getIntegerArrayList(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1028,7 +1034,8 @@ public class BaseBundle { * @param key a String, or null * @return an ArrayList<String> value, or null */ - ArrayList<String> getStringArrayList(String key) { + @Nullable + ArrayList<String> getStringArrayList(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1050,7 +1057,8 @@ public class BaseBundle { * @param key a String, or null * @return an ArrayList<CharSequence> value, or null */ - ArrayList<CharSequence> getCharSequenceArrayList(String key) { + @Nullable + ArrayList<CharSequence> getCharSequenceArrayList(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1072,7 +1080,8 @@ public class BaseBundle { * @param key a String, or null * @return a boolean[] value, or null */ - public boolean[] getBooleanArray(String key) { + @Nullable + public boolean[] getBooleanArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1094,7 +1103,8 @@ public class BaseBundle { * @param key a String, or null * @return a byte[] value, or null */ - byte[] getByteArray(String key) { + @Nullable + byte[] getByteArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1116,7 +1126,8 @@ public class BaseBundle { * @param key a String, or null * @return a short[] value, or null */ - short[] getShortArray(String key) { + @Nullable + short[] getShortArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1138,7 +1149,8 @@ public class BaseBundle { * @param key a String, or null * @return a char[] value, or null */ - char[] getCharArray(String key) { + @Nullable + char[] getCharArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1160,7 +1172,8 @@ public class BaseBundle { * @param key a String, or null * @return an int[] value, or null */ - public int[] getIntArray(String key) { + @Nullable + public int[] getIntArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1182,7 +1195,8 @@ public class BaseBundle { * @param key a String, or null * @return a long[] value, or null */ - public long[] getLongArray(String key) { + @Nullable + public long[] getLongArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1204,7 +1218,8 @@ public class BaseBundle { * @param key a String, or null * @return a float[] value, or null */ - float[] getFloatArray(String key) { + @Nullable + float[] getFloatArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1226,7 +1241,8 @@ public class BaseBundle { * @param key a String, or null * @return a double[] value, or null */ - public double[] getDoubleArray(String key) { + @Nullable + public double[] getDoubleArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1248,7 +1264,8 @@ public class BaseBundle { * @param key a String, or null * @return a String[] value, or null */ - public String[] getStringArray(String key) { + @Nullable + public String[] getStringArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -1270,7 +1287,8 @@ public class BaseBundle { * @param key a String, or null * @return a CharSequence[] value, or null */ - CharSequence[] getCharSequenceArray(String key) { + @Nullable + CharSequence[] getCharSequenceArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { diff --git a/core/java/android/os/BatteryManager.java b/core/java/android/os/BatteryManager.java index 537e993..bd5a392 100644 --- a/core/java/android/os/BatteryManager.java +++ b/core/java/android/os/BatteryManager.java @@ -162,7 +162,15 @@ public class BatteryManager { */ public static final int BATTERY_PROPERTY_ENERGY_COUNTER = 5; - private IBatteryPropertiesRegistrar mBatteryPropertiesRegistrar; + private final IBatteryPropertiesRegistrar mBatteryPropertiesRegistrar; + + /** + * @removed Was previously made visible by accident. + */ + public BatteryManager() { + mBatteryPropertiesRegistrar = IBatteryPropertiesRegistrar.Stub.asInterface( + ServiceManager.getService("batteryproperties")); + } /** * Query a battery property from the batteryproperties service. @@ -174,12 +182,7 @@ public class BatteryManager { long ret; if (mBatteryPropertiesRegistrar == null) { - IBinder b = ServiceManager.getService("batteryproperties"); - mBatteryPropertiesRegistrar = - IBatteryPropertiesRegistrar.Stub.asInterface(b); - - if (mBatteryPropertiesRegistrar == null) - return Long.MIN_VALUE; + return Long.MIN_VALUE; } try { diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java index c5c5372..c20024a 100644 --- a/core/java/android/os/Bundle.java +++ b/core/java/android/os/Bundle.java @@ -16,6 +16,7 @@ package android.os; +import android.annotation.Nullable; import android.util.ArrayMap; import android.util.Size; import android.util.SizeF; @@ -24,7 +25,6 @@ import android.util.SparseArray; import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import java.util.Set; /** * A mapping from String values to various Parcelable types. @@ -259,7 +259,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a byte */ @Override - public void putByte(String key, byte value) { + public void putByte(@Nullable String key, byte value) { super.putByte(key, value); } @@ -268,10 +268,10 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * any existing value for the given key. * * @param key a String, or null - * @param value a char, or null + * @param value a char */ @Override - public void putChar(String key, char value) { + public void putChar(@Nullable String key, char value) { super.putChar(key, value); } @@ -283,7 +283,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a short */ @Override - public void putShort(String key, short value) { + public void putShort(@Nullable String key, short value) { super.putShort(key, value); } @@ -295,7 +295,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a float */ @Override - public void putFloat(String key, float value) { + public void putFloat(@Nullable String key, float value) { super.putFloat(key, value); } @@ -307,7 +307,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a CharSequence, or null */ @Override - public void putCharSequence(String key, CharSequence value) { + public void putCharSequence(@Nullable String key, @Nullable CharSequence value) { super.putCharSequence(key, value); } @@ -318,7 +318,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @param value a Parcelable object, or null */ - public void putParcelable(String key, Parcelable value) { + public void putParcelable(@Nullable String key, @Nullable Parcelable value) { unparcel(); mMap.put(key, value); mFdsKnown = false; @@ -331,7 +331,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @param value a Size object, or null */ - public void putSize(String key, Size value) { + public void putSize(@Nullable String key, @Nullable Size value) { unparcel(); mMap.put(key, value); } @@ -343,7 +343,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @param value a SizeF object, or null */ - public void putSizeF(String key, SizeF value) { + public void putSizeF(@Nullable String key, @Nullable SizeF value) { unparcel(); mMap.put(key, value); } @@ -356,7 +356,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @param value an array of Parcelable objects, or null */ - public void putParcelableArray(String key, Parcelable[] value) { + public void putParcelableArray(@Nullable String key, @Nullable Parcelable[] value) { unparcel(); mMap.put(key, value); mFdsKnown = false; @@ -370,8 +370,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @param value an ArrayList of Parcelable objects, or null */ - public void putParcelableArrayList(String key, - ArrayList<? extends Parcelable> value) { + public void putParcelableArrayList(@Nullable String key, + @Nullable ArrayList<? extends Parcelable> value) { unparcel(); mMap.put(key, value); mFdsKnown = false; @@ -392,8 +392,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @param value a SparseArray of Parcelable objects, or null */ - public void putSparseParcelableArray(String key, - SparseArray<? extends Parcelable> value) { + public void putSparseParcelableArray(@Nullable String key, + @Nullable SparseArray<? extends Parcelable> value) { unparcel(); mMap.put(key, value); mFdsKnown = false; @@ -407,7 +407,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value an ArrayList<Integer> object, or null */ @Override - public void putIntegerArrayList(String key, ArrayList<Integer> value) { + public void putIntegerArrayList(@Nullable String key, @Nullable ArrayList<Integer> value) { super.putIntegerArrayList(key, value); } @@ -419,7 +419,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value an ArrayList<String> object, or null */ @Override - public void putStringArrayList(String key, ArrayList<String> value) { + public void putStringArrayList(@Nullable String key, @Nullable ArrayList<String> value) { super.putStringArrayList(key, value); } @@ -431,7 +431,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value an ArrayList<CharSequence> object, or null */ @Override - public void putCharSequenceArrayList(String key, ArrayList<CharSequence> value) { + public void putCharSequenceArrayList(@Nullable String key, + @Nullable ArrayList<CharSequence> value) { super.putCharSequenceArrayList(key, value); } @@ -443,7 +444,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a Serializable object, or null */ @Override - public void putSerializable(String key, Serializable value) { + public void putSerializable(@Nullable String key, @Nullable Serializable value) { super.putSerializable(key, value); } @@ -455,7 +456,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a byte array object, or null */ @Override - public void putByteArray(String key, byte[] value) { + public void putByteArray(@Nullable String key, @Nullable byte[] value) { super.putByteArray(key, value); } @@ -467,7 +468,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a short array object, or null */ @Override - public void putShortArray(String key, short[] value) { + public void putShortArray(@Nullable String key, @Nullable short[] value) { super.putShortArray(key, value); } @@ -479,7 +480,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a char array object, or null */ @Override - public void putCharArray(String key, char[] value) { + public void putCharArray(@Nullable String key, @Nullable char[] value) { super.putCharArray(key, value); } @@ -491,7 +492,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a float array object, or null */ @Override - public void putFloatArray(String key, float[] value) { + public void putFloatArray(@Nullable String key, @Nullable float[] value) { super.putFloatArray(key, value); } @@ -503,7 +504,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param value a CharSequence array object, or null */ @Override - public void putCharSequenceArray(String key, CharSequence[] value) { + public void putCharSequenceArray(@Nullable String key, @Nullable CharSequence[] value) { super.putCharSequenceArray(key, value); } @@ -514,7 +515,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @param value a Bundle object, or null */ - public void putBundle(String key, Bundle value) { + public void putBundle(@Nullable String key, @Nullable Bundle value) { unparcel(); mMap.put(key, value); } @@ -533,7 +534,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @param value an IBinder object, or null */ - public void putBinder(String key, IBinder value) { + public void putBinder(@Nullable String key, @Nullable IBinder value) { unparcel(); mMap.put(key, value); } @@ -549,7 +550,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @hide This is the old name of the function. */ @Deprecated - public void putIBinder(String key, IBinder value) { + public void putIBinder(@Nullable String key, @Nullable IBinder value) { unparcel(); mMap.put(key, value); } @@ -663,7 +664,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return a CharSequence value, or null */ @Override - public CharSequence getCharSequence(String key) { + @Nullable + public CharSequence getCharSequence(@Nullable String key) { return super.getCharSequence(key); } @@ -679,7 +681,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * if no valid CharSequence object is currently mapped to that key. */ @Override - public CharSequence getCharSequence(String key, CharSequence defaultValue) { + public CharSequence getCharSequence(@Nullable String key, CharSequence defaultValue) { return super.getCharSequence(key, defaultValue); } @@ -691,7 +693,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @return a Size value, or null */ - public Size getSize(String key) { + @Nullable + public Size getSize(@Nullable String key) { unparcel(); final Object o = mMap.get(key); try { @@ -710,7 +713,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @return a Size value, or null */ - public SizeF getSizeF(String key) { + @Nullable + public SizeF getSizeF(@Nullable String key) { unparcel(); final Object o = mMap.get(key); try { @@ -729,7 +733,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @return a Bundle value, or null */ - public Bundle getBundle(String key) { + @Nullable + public Bundle getBundle(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -751,7 +756,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @return a Parcelable value, or null */ - public <T extends Parcelable> T getParcelable(String key) { + @Nullable + public <T extends Parcelable> T getParcelable(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -773,7 +779,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @return a Parcelable[] value, or null */ - public Parcelable[] getParcelableArray(String key) { + @Nullable + public Parcelable[] getParcelableArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -795,7 +802,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @return an ArrayList<T> value, or null */ - public <T extends Parcelable> ArrayList<T> getParcelableArrayList(String key) { + @Nullable + public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -818,7 +826,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * * @return a SparseArray of T values, or null */ - public <T extends Parcelable> SparseArray<T> getSparseParcelableArray(String key) { + @Nullable + public <T extends Parcelable> SparseArray<T> getSparseParcelableArray(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -841,7 +850,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return a Serializable value, or null */ @Override - public Serializable getSerializable(String key) { + @Nullable + public Serializable getSerializable(@Nullable String key) { return super.getSerializable(key); } @@ -854,7 +864,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return an ArrayList<String> value, or null */ @Override - public ArrayList<Integer> getIntegerArrayList(String key) { + @Nullable + public ArrayList<Integer> getIntegerArrayList(@Nullable String key) { return super.getIntegerArrayList(key); } @@ -867,7 +878,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return an ArrayList<String> value, or null */ @Override - public ArrayList<String> getStringArrayList(String key) { + @Nullable + public ArrayList<String> getStringArrayList(@Nullable String key) { return super.getStringArrayList(key); } @@ -880,7 +892,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return an ArrayList<CharSequence> value, or null */ @Override - public ArrayList<CharSequence> getCharSequenceArrayList(String key) { + @Nullable + public ArrayList<CharSequence> getCharSequenceArrayList(@Nullable String key) { return super.getCharSequenceArrayList(key); } @@ -893,7 +906,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return a byte[] value, or null */ @Override - public byte[] getByteArray(String key) { + @Nullable + public byte[] getByteArray(@Nullable String key) { return super.getByteArray(key); } @@ -906,7 +920,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return a short[] value, or null */ @Override - public short[] getShortArray(String key) { + @Nullable + public short[] getShortArray(@Nullable String key) { return super.getShortArray(key); } @@ -919,7 +934,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return a char[] value, or null */ @Override - public char[] getCharArray(String key) { + @Nullable + public char[] getCharArray(@Nullable String key) { return super.getCharArray(key); } @@ -932,7 +948,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return a float[] value, or null */ @Override - public float[] getFloatArray(String key) { + @Nullable + public float[] getFloatArray(@Nullable String key) { return super.getFloatArray(key); } @@ -945,7 +962,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @return a CharSequence[] value, or null */ @Override - public CharSequence[] getCharSequenceArray(String key) { + @Nullable + public CharSequence[] getCharSequenceArray(@Nullable String key) { return super.getCharSequenceArray(key); } @@ -957,7 +975,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @param key a String, or null * @return an IBinder value, or null */ - public IBinder getBinder(String key) { + @Nullable + public IBinder getBinder(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { @@ -983,7 +1002,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { * @hide This is the old name of the function. */ @Deprecated - public IBinder getIBinder(String key) { + @Nullable + public IBinder getIBinder(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { diff --git a/core/java/android/os/CommonClock.java b/core/java/android/os/CommonClock.java index f83a90b..2ecf317 100644 --- a/core/java/android/os/CommonClock.java +++ b/core/java/android/os/CommonClock.java @@ -23,7 +23,6 @@ import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; import android.os.ServiceManager; -import static android.system.OsConstants.*; /** * Used for accessing the android common time service's common clock and receiving notifications diff --git a/core/java/android/os/PersistableBundle.java b/core/java/android/os/PersistableBundle.java index 3a44428..a467c87 100644 --- a/core/java/android/os/PersistableBundle.java +++ b/core/java/android/os/PersistableBundle.java @@ -16,6 +16,7 @@ package android.os; +import android.annotation.Nullable; import android.util.ArrayMap; import com.android.internal.util.XmlUtils; import org.xmlpull.v1.XmlPullParser; @@ -135,7 +136,7 @@ public final class PersistableBundle extends BaseBundle implements Cloneable, Pa * @param key a String, or null * @param value a Bundle object, or null */ - public void putPersistableBundle(String key, PersistableBundle value) { + public void putPersistableBundle(@Nullable String key, @Nullable PersistableBundle value) { unparcel(); mMap.put(key, value); } @@ -148,7 +149,8 @@ public final class PersistableBundle extends BaseBundle implements Cloneable, Pa * @param key a String, or null * @return a Bundle value, or null */ - public PersistableBundle getPersistableBundle(String key) { + @Nullable + public PersistableBundle getPersistableBundle(@Nullable String key) { unparcel(); Object o = mMap.get(key); if (o == null) { diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java index 74e064e..6874e77 100644 --- a/core/java/android/os/UserHandle.java +++ b/core/java/android/os/UserHandle.java @@ -20,7 +20,6 @@ import android.annotation.SystemApi; import android.util.SparseArray; import java.io.PrintWriter; -import java.util.HashMap; /** * Representation of a user on the device. diff --git a/core/java/android/preference/GenericInflater.java b/core/java/android/preference/GenericInflater.java index c84dbf1..918933b 100644 --- a/core/java/android/preference/GenericInflater.java +++ b/core/java/android/preference/GenericInflater.java @@ -23,7 +23,6 @@ import java.util.HashMap; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -import android.annotation.AnyRes; import android.annotation.XmlRes; import android.content.Context; import android.content.res.XmlResourceParser; diff --git a/core/java/android/preference/PreferenceGroup.java b/core/java/android/preference/PreferenceGroup.java index 2d35b1b..5e84086 100644 --- a/core/java/android/preference/PreferenceGroup.java +++ b/core/java/android/preference/PreferenceGroup.java @@ -19,12 +19,9 @@ package android.preference; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; - import android.content.Context; import android.content.res.TypedArray; import android.os.Bundle; -import android.os.Parcelable; import android.text.TextUtils; import android.util.AttributeSet; diff --git a/core/java/android/printservice/PrintService.java b/core/java/android/printservice/PrintService.java index 7ed1649..527c8ae 100644 --- a/core/java/android/printservice/PrintService.java +++ b/core/java/android/printservice/PrintService.java @@ -16,7 +16,6 @@ package android.printservice; -import android.R; import android.app.Service; import android.content.ComponentName; import android.content.Context; diff --git a/core/java/android/provider/Browser.java b/core/java/android/provider/Browser.java index 3853003..69a05c4 100644 --- a/core/java/android/provider/Browser.java +++ b/core/java/android/provider/Browser.java @@ -25,7 +25,6 @@ import android.database.Cursor; import android.database.DatabaseUtils; import android.graphics.BitmapFactory; import android.net.Uri; -import android.os.Build; import android.provider.BrowserContract.Bookmarks; import android.provider.BrowserContract.Combined; import android.provider.BrowserContract.History; diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index 266922d..2df9dbf 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -38,6 +38,7 @@ import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; +import android.util.Log; import com.android.internal.telephony.CallerInfo; import com.android.internal.telephony.PhoneConstants; @@ -48,6 +49,8 @@ import java.util.List; * The CallLog provider contains information about placed and received calls. */ public class CallLog { + private static final String LOG_TAG = "CallLog"; + public static final String AUTHORITY = "call_log"; /** @@ -359,6 +362,15 @@ public class CallLog { public static final String PHONE_ACCOUNT_ADDRESS = "phone_account_address"; /** + * Indicates that the entry will be hidden from all queries until the associated + * {@link android.telecom.PhoneAccount} is registered with the system. + * <P>Type: INTEGER</P> + * + * @hide + */ + public static final String PHONE_ACCOUNT_HIDDEN = "phone_account_hidden"; + + /** * The subscription ID used to place this call. This is no longer used and has been * replaced with PHONE_ACCOUNT_COMPONENT_NAME/PHONE_ACCOUNT_ID. * For ContactsProvider internal use only. @@ -434,6 +446,7 @@ public class CallLog { long start, int duration, Long dataUsage, boolean addForAllUsers) { final ContentResolver resolver = context.getContentResolver(); int numberPresentation = PRESENTATION_ALLOWED; + boolean isHidden = false; TelecomManager tm = null; try { @@ -444,7 +457,16 @@ public class CallLog { if (tm != null && accountHandle != null) { PhoneAccount account = tm.getPhoneAccount(accountHandle); if (account != null) { - accountAddress = account.getSubscriptionAddress().getSchemeSpecificPart(); + Uri address = account.getSubscriptionAddress(); + if (address != null) { + accountAddress = address.getSchemeSpecificPart(); + } + } else { + // We could not find the account through telecom. For call log entries that + // are added with a phone account which is not registered, we automatically + // mark them as hidden. They are unhidden once the account is registered. + Log.i(LOG_TAG, "Marking call log entry as hidden."); + isHidden = true; } } @@ -490,6 +512,7 @@ public class CallLog { values.put(PHONE_ACCOUNT_COMPONENT_NAME, accountComponentString); values.put(PHONE_ACCOUNT_ID, accountId); values.put(PHONE_ACCOUNT_ADDRESS, accountAddress); + values.put(PHONE_ACCOUNT_HIDDEN, Integer.valueOf(isHidden ? 1 : 0)); values.put(NEW, Integer.valueOf(1)); if (callType == MISSED_TYPE) { diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 67ac043..9cc12b5 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -8069,6 +8069,14 @@ public final class ContactsContract { public static final String EXTRA_MODE = "android.provider.extra.MODE"; /** + * Extra used to specify which mimetype should be prioritized in the QuickContacts UI. + * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can + * cause phone numbers to be displayed more prominently in QuickContacts. + */ + public static final String EXTRA_PRIORITIZED_MIMETYPE + = "android.provider.extra.PRIORITIZED_MIMETYPE"; + + /** * Extra used to indicate a list of specific MIME-types to exclude and not display in the * QuickContacts dialog. Stored as a {@link String} array. */ @@ -8206,6 +8214,80 @@ public final class ContactsContract { startActivityWithErrorToast(context, intent); } + /** + * Trigger a dialog that lists the various methods of interacting with + * the requested {@link Contacts} entry. This may be based on available + * {@link ContactsContract.Data} rows under that contact, and may also + * include social status and presence details. + * + * @param context The parent {@link Context} that may be used as the + * parent for this dialog. + * @param target Specific {@link View} from your layout that this dialog + * should be centered around. In particular, if the dialog + * has a "callout" arrow, it will be pointed and centered + * around this {@link View}. + * @param lookupUri A + * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style + * {@link Uri} that describes a specific contact to feature + * in this dialog. + * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types + * to exclude when showing this dialog. For example, when + * already viewing the contact details card, this can be used + * to omit the details entry from the dialog. + * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. + * For example, passing the value + * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be + * displayed more prominently in QuickContacts. + */ + public static void showQuickContact(Context context, View target, Uri lookupUri, + String[] excludeMimes, String prioritizedMimeType) { + // Use MODE_LARGE instead of accepting mode as a parameter. The different mode + // values defined in ContactsContract only affect very old implementations + // of QuickContacts. + Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_LARGE, + excludeMimes); + intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); + startActivityWithErrorToast(context, intent); + } + + /** + * Trigger a dialog that lists the various methods of interacting with + * the requested {@link Contacts} entry. This may be based on available + * {@link ContactsContract.Data} rows under that contact, and may also + * include social status and presence details. + * + * @param context The parent {@link Context} that may be used as the + * parent for this dialog. + * @param target Specific {@link Rect} that this dialog should be + * centered around, in screen coordinates. In particular, if + * the dialog has a "callout" arrow, it will be pointed and + * centered around this {@link Rect}. If you are running at a + * non-native density, you need to manually adjust using + * {@link DisplayMetrics#density} before calling. + * @param lookupUri A + * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style + * {@link Uri} that describes a specific contact to feature + * in this dialog. + * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types + * to exclude when showing this dialog. For example, when + * already viewing the contact details card, this can be used + * to omit the details entry from the dialog. + * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. + * For example, passing the value + * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be + * displayed more prominently in QuickContacts. + */ + public static void showQuickContact(Context context, Rect target, Uri lookupUri, + String[] excludeMimes, String prioritizedMimeType) { + // Use MODE_LARGE instead of accepting mode as a parameter. The different mode + // values defined in ContactsContract only affect very old implementations + // of QuickContacts. + Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_LARGE, + excludeMimes); + intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); + startActivityWithErrorToast(context, intent); + } + private static void startActivityWithErrorToast(Context context, Intent intent) { try { context.startActivity(intent); diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index f084263..c60a906 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -65,7 +65,6 @@ import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.regex.Pattern; /** * The Settings provider contains global system-level device preferences. diff --git a/core/java/android/security/keymaster/KeyCharacteristics.java b/core/java/android/security/keymaster/KeyCharacteristics.java index b803a1b..0f1d422 100644 --- a/core/java/android/security/keymaster/KeyCharacteristics.java +++ b/core/java/android/security/keymaster/KeyCharacteristics.java @@ -19,8 +19,6 @@ package android.security.keymaster; import android.os.Parcel; import android.os.Parcelable; -import java.util.List; - /** * @hide */ diff --git a/core/java/android/security/keymaster/KeymasterBlobArgument.java b/core/java/android/security/keymaster/KeymasterBlobArgument.java index 27f1153..9af4445 100644 --- a/core/java/android/security/keymaster/KeymasterBlobArgument.java +++ b/core/java/android/security/keymaster/KeymasterBlobArgument.java @@ -17,7 +17,6 @@ package android.security.keymaster; import android.os.Parcel; -import android.os.Parcelable; /** * @hide diff --git a/core/java/android/security/keymaster/KeymasterBooleanArgument.java b/core/java/android/security/keymaster/KeymasterBooleanArgument.java index 8e17db4..5481e8f 100644 --- a/core/java/android/security/keymaster/KeymasterBooleanArgument.java +++ b/core/java/android/security/keymaster/KeymasterBooleanArgument.java @@ -17,7 +17,6 @@ package android.security.keymaster; import android.os.Parcel; -import android.os.Parcelable; /** * @hide diff --git a/core/java/android/security/keymaster/KeymasterDateArgument.java b/core/java/android/security/keymaster/KeymasterDateArgument.java index e8f4055..310f546 100644 --- a/core/java/android/security/keymaster/KeymasterDateArgument.java +++ b/core/java/android/security/keymaster/KeymasterDateArgument.java @@ -17,8 +17,6 @@ package android.security.keymaster; import android.os.Parcel; -import android.os.Parcelable; - import java.util.Date; /** diff --git a/core/java/android/security/keymaster/KeymasterIntArgument.java b/core/java/android/security/keymaster/KeymasterIntArgument.java index 71797ae..c3738d7 100644 --- a/core/java/android/security/keymaster/KeymasterIntArgument.java +++ b/core/java/android/security/keymaster/KeymasterIntArgument.java @@ -17,7 +17,6 @@ package android.security.keymaster; import android.os.Parcel; -import android.os.Parcelable; /** * @hide diff --git a/core/java/android/security/keymaster/KeymasterLongArgument.java b/core/java/android/security/keymaster/KeymasterLongArgument.java index 781b1ab..3c565b8 100644 --- a/core/java/android/security/keymaster/KeymasterLongArgument.java +++ b/core/java/android/security/keymaster/KeymasterLongArgument.java @@ -17,7 +17,6 @@ package android.security.keymaster; import android.os.Parcel; -import android.os.Parcelable; /** * @hide diff --git a/core/java/android/security/keymaster/OperationResult.java b/core/java/android/security/keymaster/OperationResult.java index ad54c96..4fc9d24 100644 --- a/core/java/android/security/keymaster/OperationResult.java +++ b/core/java/android/security/keymaster/OperationResult.java @@ -20,8 +20,6 @@ import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; -import java.util.List; - /** * Class for handling the parceling of return values from keymaster crypto operations * (begin/update/finish). diff --git a/core/java/android/service/carrier/CarrierMessagingService.java b/core/java/android/service/carrier/CarrierMessagingService.java index 3d6ebca..0592a84 100644 --- a/core/java/android/service/carrier/CarrierMessagingService.java +++ b/core/java/android/service/carrier/CarrierMessagingService.java @@ -23,11 +23,8 @@ import android.app.Service; import android.content.Intent; import android.net.Uri; import android.os.IBinder; -import android.os.Parcel; -import android.os.Parcelable; import android.os.RemoteException; -import java.util.ArrayList; import java.util.List; /** diff --git a/core/java/android/service/fingerprint/FingerprintManager.java b/core/java/android/service/fingerprint/FingerprintManager.java index 178cc8b..731709b 100644 --- a/core/java/android/service/fingerprint/FingerprintManager.java +++ b/core/java/android/service/fingerprint/FingerprintManager.java @@ -17,11 +17,8 @@ package android.service.fingerprint; import android.app.ActivityManagerNative; -import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; import android.os.Binder; import android.os.Handler; import android.os.IBinder; @@ -31,6 +28,9 @@ import android.provider.Settings; import android.util.Log; import android.util.Slog; +import java.util.ArrayList; +import java.util.List; + /** * A class that coordinates access to the fingerprint hardware. * @hide @@ -97,6 +97,15 @@ public class FingerprintManager { } }; + public static final class FingerprintItem { + CharSequence name; + int id; + FingerprintItem(CharSequence name, int id) { + this.name = name; + this.id = id; + } + } + /** * @hide */ @@ -248,4 +257,38 @@ public class FingerprintManager { private void sendError(int msg, int arg1, int arg2) { mHandler.obtainMessage(msg, arg1, arg2); } + + /** + * @return list of current fingerprint items + * @hide + */ + public List<FingerprintItem> getEnrolledFingerprints() { + int[] ids = FingerprintUtils.getFingerprintIdsForUser(mContext.getContentResolver(), + getCurrentUserId()); + List<FingerprintItem> result = new ArrayList<FingerprintItem>(); + for (int i = 0; i < ids.length; i++) { + // TODO: persist names in Settings + FingerprintItem item = new FingerprintItem("Finger" + ids[i], ids[i]); + result.add(item); + } + return result; + } + + /** + * Determine if fingerprint hardware is present and functional. + * @return true if hardware is present and functional, false otherwise. + * @hide + */ + public boolean isHardwareDetected() { + if (mService != null) { + try { + return mService.isHardwareDetected(); + } catch (RemoteException e) { + Log.v(TAG, "Remote exception in isFingerprintHardwareDetected(): ", e); + } + } else { + Log.w(TAG, "isFingerprintHardwareDetected(): Service not connected!"); + } + return false; + } }
\ No newline at end of file diff --git a/core/java/android/service/fingerprint/FingerprintUtils.java b/core/java/android/service/fingerprint/FingerprintUtils.java index a4caf8e..cc17b99 100644 --- a/core/java/android/service/fingerprint/FingerprintUtils.java +++ b/core/java/android/service/fingerprint/FingerprintUtils.java @@ -21,7 +21,11 @@ import android.provider.Settings; import android.text.TextUtils; import android.util.Log; +import com.android.internal.util.ArrayUtils; + +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; /** * Utility class for dealing with fingerprints and fingerprint settings. @@ -32,34 +36,50 @@ class FingerprintUtils { private static final boolean DEBUG = true; private static final String TAG = "FingerprintUtils"; + private static int[] toIntArray(List<Integer> list) { + if (list == null) { + return null; + } + int[] arr = new int[list.size()]; + int i = 0; + for (int elem : list) { + arr[i] = elem; + i++; + } + return arr; + } + public static int[] getFingerprintIdsForUser(ContentResolver res, int userId) { String fingerIdsRaw = Settings.Secure.getStringForUser(res, Settings.Secure.USER_FINGERPRINT_IDS, userId); - - int result[] = {}; + ArrayList<Integer> tmp = new ArrayList<Integer>(); if (!TextUtils.isEmpty(fingerIdsRaw)) { String[] fingerStringIds = fingerIdsRaw.replace("[","").replace("]","").split(", "); - result = new int[fingerStringIds.length]; - for (int i = 0; i < result.length; i++) { + int length = fingerStringIds.length; + for (int i = 0; i < length; i++) { try { - result[i] = Integer.decode(fingerStringIds[i]); + tmp.add(Integer.decode(fingerStringIds[i])); } catch (NumberFormatException e) { - if (DEBUG) Log.d(TAG, "Error when parsing finger id " + fingerStringIds[i]); + if (DEBUG) Log.w(TAG, "Error parsing finger id: '" + fingerStringIds[i] + "'"); } } } - return result; + return toIntArray(tmp); } public static void addFingerprintIdForUser(int fingerId, ContentResolver res, int userId) { - int[] fingerIds = getFingerprintIdsForUser(res, userId); - // FingerId 0 has special meaning. - if (fingerId == 0) return; + if (fingerId == 0) { + Log.w(TAG, "Tried to add fingerId 0"); + return; + } + + int[] fingerIds = getFingerprintIdsForUser(res, userId); // Don't allow dups - for (int i = 0; i < fingerIds.length; i++) { - if (fingerIds[i] == fingerId) return; + if (ArrayUtils.contains(fingerIds, fingerId)) { + Log.w(TAG, "finger already added " + fingerId); + return; } int[] newList = Arrays.copyOf(fingerIds, fingerIds.length + 1); newList[fingerIds.length] = fingerId; @@ -72,19 +92,13 @@ class FingerprintUtils { // FingerId 0 has special meaning. The HAL layer is supposed to remove each finger one // at a time and invoke notify() for each fingerId. If we get called with 0 here, it means // something bad has happened. - if (fingerId == 0) throw new IllegalStateException("Bad fingerId"); + if (fingerId == 0) throw new IllegalArgumentException("fingerId can't be 0"); - int[] fingerIds = getFingerprintIdsForUser(res, userId); - int[] resultIds = Arrays.copyOf(fingerIds, fingerIds.length); - int resultCount = 0; - for (int i = 0; i < fingerIds.length; i++) { - if (fingerId != fingerIds[i]) { - resultIds[resultCount++] = fingerIds[i]; - } - } - if (resultCount > 0) { + final int[] fingerIds = getFingerprintIdsForUser(res, userId); + if (ArrayUtils.contains(fingerIds, fingerId)) { + final int[] result = ArrayUtils.removeInt(fingerIds, fingerId); Settings.Secure.putStringForUser(res, Settings.Secure.USER_FINGERPRINT_IDS, - Arrays.toString(Arrays.copyOf(resultIds, resultCount)), userId); + Arrays.toString(result), userId); return true; } return false; diff --git a/core/java/android/service/fingerprint/IFingerprintService.aidl b/core/java/android/service/fingerprint/IFingerprintService.aidl index 43d5e9a..a7d4090 100644 --- a/core/java/android/service/fingerprint/IFingerprintService.aidl +++ b/core/java/android/service/fingerprint/IFingerprintService.aidl @@ -22,10 +22,10 @@ import android.service.fingerprint.IFingerprintServiceReceiver; * Communication channel from client to the fingerprint service. * @hide */ -oneway interface IFingerprintService { +interface IFingerprintService { // Any errors resulting from this call will be returned to the listener void enroll(IBinder token, long timeout, int userId); - + // Any errors resulting from this call will be returned to the listener void enrollCancel(IBinder token, int userId); @@ -38,4 +38,7 @@ oneway interface IFingerprintService { // Stops listening for fingerprints void stopListening(IBinder token, int userId); + + // Determine if HAL is loaded and ready + boolean isHardwareDetected(); } diff --git a/core/java/android/service/restrictions/RestrictionsReceiver.java b/core/java/android/service/restrictions/RestrictionsReceiver.java index 7c6e1f6..b830cb1 100644 --- a/core/java/android/service/restrictions/RestrictionsReceiver.java +++ b/core/java/android/service/restrictions/RestrictionsReceiver.java @@ -21,7 +21,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.RestrictionsManager; -import android.os.IBinder; import android.os.PersistableBundle; /** diff --git a/core/java/android/service/trust/TrustAgentService.java b/core/java/android/service/trust/TrustAgentService.java index 62fa978..706b934 100644 --- a/core/java/android/service/trust/TrustAgentService.java +++ b/core/java/android/service/trust/TrustAgentService.java @@ -25,13 +25,10 @@ import android.content.ComponentName; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; -import android.os.Bundle; import android.os.Handler; import android.os.IBinder; -import android.os.Message; import android.os.PersistableBundle; import android.os.RemoteException; -import android.os.SystemClock; import android.util.Log; import android.util.Slog; diff --git a/core/java/android/service/voice/IVoiceInteractionSession.aidl b/core/java/android/service/voice/IVoiceInteractionSession.aidl index a8c0c4c..797457a 100644 --- a/core/java/android/service/voice/IVoiceInteractionSession.aidl +++ b/core/java/android/service/voice/IVoiceInteractionSession.aidl @@ -23,6 +23,8 @@ import android.os.Bundle; * @hide */ oneway interface IVoiceInteractionSession { + void show(in Bundle sessionArgs, int flags); + void hide(); void handleAssist(in Bundle assistData); void taskStarted(in Intent intent, int taskId); void taskFinished(in Intent intent, int taskId); diff --git a/core/java/android/service/voice/VoiceInteractionService.java b/core/java/android/service/voice/VoiceInteractionService.java index 54a3a0a..0c01b25 100644 --- a/core/java/android/service/voice/VoiceInteractionService.java +++ b/core/java/android/service/voice/VoiceInteractionService.java @@ -71,7 +71,7 @@ public class VoiceInteractionService extends Service { public static final String SERVICE_META_DATA = "android.voice_interaction"; /** - * Flag for use with {@link #startSession}: request that the session be started with + * Flag for use with {@link #showSession: request that the session be started with * assist data from the currently focused activity. */ public static final int START_WITH_ASSIST = 1<<0; @@ -139,20 +139,25 @@ public class VoiceInteractionService extends Service { } /** - * Initiate the execution of a new {@link android.service.voice.VoiceInteractionSession}. + * Request that the associated {@link android.service.voice.VoiceInteractionSession} be + * shown to the user, starting it if necessary. * @param args Arbitrary arguments that will be propagated to the session. */ - public void startSession(Bundle args, int flags) { + public void showSession(Bundle args, int flags) { if (mSystemService == null) { throw new IllegalStateException("Not available until onReady() is called"); } try { - mSystemService.startSession(mInterface, args, flags); + mSystemService.showSession(mInterface, args, flags); } catch (RemoteException e) { } } /** @hide */ + public void startSession(Bundle args, int flags) { + showSession(args, flags); + } + /** @hide */ public void startSession(Bundle args) { startSession(args, 0); } @@ -174,7 +179,7 @@ public class VoiceInteractionService extends Service { /** * Called during service initialization to tell you when the system is ready * to receive interaction from it. You should generally do initialization here - * rather than in {@link #onCreate}. Methods such as {@link #startSession} and + * rather than in {@link #onCreate}. Methods such as {@link #showSession} and * {@link #createAlwaysOnHotwordDetector} * will not be operational until this point. */ diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java index a3a2ca1..4cf0e4c 100644 --- a/core/java/android/service/voice/VoiceInteractionSession.java +++ b/core/java/android/service/voice/VoiceInteractionSession.java @@ -53,10 +53,9 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; /** * An active voice interaction session, providing a facility for the implementation - * to interact with the user in the voice interaction layer. This interface is no shown - * by default, but you can request that it be shown with {@link #showWindow()}, which - * will result in a later call to {@link #onCreateContentView()} in which the UI can be - * built + * to interact with the user in the voice interaction layer. The user interface is + * initially shown by default, and can be created be overriding {@link #onCreateContentView()} + * in which the UI can be built. * * <p>A voice interaction session can be self-contained, ultimately calling {@link #finish} * when done. It can also initiate voice interactions with applications by calling @@ -151,6 +150,17 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { final IVoiceInteractionSession mSession = new IVoiceInteractionSession.Stub() { @Override + public void show(Bundle sessionArgs, int flags) { + mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageIO(MSG_SHOW, + flags, sessionArgs)); + } + + @Override + public void hide() { + mHandlerCaller.sendMessage(mHandlerCaller.obtainMessage(MSG_HIDE)); + } + + @Override public void handleAssist(Bundle assistBundle) { mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(MSG_HANDLE_ASSIST, assistBundle)); @@ -284,6 +294,8 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { static final int MSG_CLOSE_SYSTEM_DIALOGS = 102; static final int MSG_DESTROY = 103; static final int MSG_HANDLE_ASSIST = 104; + static final int MSG_SHOW = 105; + static final int MSG_HIDE = 106; class MyCallbacks implements HandlerCaller.Callback, SoftInputWindow.Callback { @Override @@ -324,9 +336,8 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { args.arg1 = onGetSupportedCommands((Caller) args.arg1, (String[]) args.arg2); break; case MSG_CANCEL: - args = (SomeArgs)msg.obj; - if (DEBUG) Log.d(TAG, "onCancel: req=" + ((Request) args.arg1).mInterface); - onCancel((Request)args.arg1); + if (DEBUG) Log.d(TAG, "onCancel: req=" + ((Request)msg.obj)); + onCancel((Request)msg.obj); break; case MSG_TASK_STARTED: if (DEBUG) Log.d(TAG, "onTaskStarted: intent=" + msg.obj @@ -350,6 +361,15 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { if (DEBUG) Log.d(TAG, "onHandleAssist: " + (Bundle)msg.obj); onHandleAssist((Bundle) msg.obj); break; + case MSG_SHOW: + if (DEBUG) Log.d(TAG, "doShow: args=" + msg.obj + + " flags=" + msg.arg1); + doShow((Bundle) msg.obj, msg.arg1); + break; + case MSG_HIDE: + if (DEBUG) Log.d(TAG, "doHide"); + doHide(); + break; } } @@ -457,6 +477,45 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { onCreate(args, startFlags); } + void doShow(Bundle args, int flags) { + if (DEBUG) Log.v(TAG, "Showing window: mWindowAdded=" + mWindowAdded + + " mWindowVisible=" + mWindowVisible); + + if (mInShowWindow) { + Log.w(TAG, "Re-entrance in to showWindow"); + return; + } + + try { + mInShowWindow = true; + if (!mWindowVisible) { + if (!mWindowAdded) { + mWindowAdded = true; + View v = onCreateContentView(); + if (v != null) { + setContentView(v); + } + } + } + onShow(args, flags); + if (!mWindowVisible) { + mWindowVisible = true; + mWindow.show(); + } + } finally { + mWindowWasVisible = true; + mInShowWindow = false; + } + } + + void doHide() { + if (mWindowVisible) { + mWindow.hide(); + mWindowVisible = false; + onHide(); + } + } + void doDestroy() { onDestroy(); if (mInitialized) { @@ -484,39 +543,26 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { mContentFrame = (FrameLayout)mRootView.findViewById(android.R.id.content); } - public void showWindow() { - if (DEBUG) Log.v(TAG, "Showing window: mWindowAdded=" + mWindowAdded - + " mWindowVisible=" + mWindowVisible); - - if (mInShowWindow) { - Log.w(TAG, "Re-entrance in to showWindow"); - return; + public void show() { + try { + mSystemService.showSessionFromSession(mToken, null, 0); + } catch (RemoteException e) { } + } + public void hide() { try { - mInShowWindow = true; - if (!mWindowVisible) { - mWindowVisible = true; - if (!mWindowAdded) { - mWindowAdded = true; - View v = onCreateContentView(); - if (v != null) { - setContentView(v); - } - } - mWindow.show(); - } - } finally { - mWindowWasVisible = true; - mInShowWindow = false; + mSystemService.hideSessionFromSession(mToken); + } catch (RemoteException e) { } } + /** TODO: remove */ + public void showWindow() { + } + + /** TODO: remove */ public void hideWindow() { - if (mWindowVisible) { - mWindow.hide(); - mWindowVisible = false; - } } /** @@ -611,15 +657,33 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { } /** - * Initiatize a new session. + * Initiatize a new session. The given args and showFlags are the initial values + * passed to {@link VoiceInteractionService#showSession VoiceInteractionService.showSession}, + * if possible. Normally you should handle these in {@link #onShow}. + */ + public void onCreate(Bundle args, int showFlags) { + onCreate(args); + } + + /** + * Called when the session UI is going to be shown. This is called after + * {@link #onCreateContentView} (if the session's content UI needed to be created) and + * immediately prior to the window being shown. This may be called while the window + * is already shown, if a show request has come in while it is shown, to allow you to + * update the UI to match the new show arguments. * * @param args The arguments that were supplied to - * {@link VoiceInteractionService#startSession VoiceInteractionService.startSession}. - * @param startFlags The start flags originally provided to - * {@link VoiceInteractionService#startSession VoiceInteractionService.startSession}. + * {@link VoiceInteractionService#showSession VoiceInteractionService.showSession}. + * @param showFlags The show flags originally provided to + * {@link VoiceInteractionService#showSession VoiceInteractionService.showSession}. */ - public void onCreate(Bundle args, int startFlags) { - onCreate(args); + public void onShow(Bundle args, int showFlags) { + } + + /** + * Called immediately after stopping to show the session UI. + */ + public void onHide() { } /** @@ -663,7 +727,7 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { } public void onBackPressed() { - finish(); + hide(); } /** @@ -672,7 +736,7 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { * calls {@link #finish}. */ public void onCloseSystemDialogs() { - finish(); + hide(); } /** @@ -717,7 +781,7 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { * @param taskId Unique ID of the finished task. */ public void onTaskFinished(Intent intent, int taskId) { - finish(); + hide(); } /** diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 9496b53..4902a71 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -64,8 +64,6 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; -import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; - /** * A wallpaper service is responsible for showing a live wallpaper behind * applications that would like to sit on top of it. This service object diff --git a/core/java/android/speech/tts/AudioPlaybackQueueItem.java b/core/java/android/speech/tts/AudioPlaybackQueueItem.java index b4ac429..d4fea53 100644 --- a/core/java/android/speech/tts/AudioPlaybackQueueItem.java +++ b/core/java/android/speech/tts/AudioPlaybackQueueItem.java @@ -17,7 +17,6 @@ package android.speech.tts; import android.content.Context; import android.media.AudioSystem; -import android.media.AudioTrack; import android.media.MediaPlayer; import android.net.Uri; import android.os.ConditionVariable; diff --git a/core/java/android/speech/tts/BlockingAudioTrack.java b/core/java/android/speech/tts/BlockingAudioTrack.java index dc4e9d3..9920ea1 100644 --- a/core/java/android/speech/tts/BlockingAudioTrack.java +++ b/core/java/android/speech/tts/BlockingAudioTrack.java @@ -2,7 +2,6 @@ package android.speech.tts; -import android.media.AudioAttributes; import android.media.AudioFormat; import android.media.AudioTrack; import android.speech.tts.TextToSpeechService.AudioOutputParams; diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java index f0ad951..668e028 100644 --- a/core/java/android/speech/tts/TextToSpeech.java +++ b/core/java/android/speech/tts/TextToSpeech.java @@ -38,7 +38,6 @@ import android.util.Log; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; diff --git a/core/java/android/speech/tts/TextToSpeechService.java b/core/java/android/speech/tts/TextToSpeechService.java index 02c9a36..ba98f27 100644 --- a/core/java/android/speech/tts/TextToSpeechService.java +++ b/core/java/android/speech/tts/TextToSpeechService.java @@ -39,11 +39,9 @@ import android.util.Log; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.MissingResourceException; import java.util.Set; diff --git a/core/java/android/speech/tts/TtsEngines.java b/core/java/android/speech/tts/TtsEngines.java index df6c010..412eba3 100644 --- a/core/java/android/speech/tts/TtsEngines.java +++ b/core/java/android/speech/tts/TtsEngines.java @@ -17,7 +17,6 @@ package android.speech.tts; import org.xmlpull.v1.XmlPullParserException; -import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; diff --git a/core/java/android/text/MeasuredText.java b/core/java/android/text/MeasuredText.java index 2415b11..e72e18f 100644 --- a/core/java/android/text/MeasuredText.java +++ b/core/java/android/text/MeasuredText.java @@ -16,7 +16,6 @@ package android.text; -import android.graphics.Canvas; import android.graphics.Paint; import android.text.style.MetricAffectingSpan; import android.text.style.ReplacementSpan; diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index 2d4b4dc..ffb7d36 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -16,7 +16,6 @@ package android.text; -import android.graphics.Bitmap; import android.graphics.Paint; import android.text.style.LeadingMarginSpan; import android.text.style.LeadingMarginSpan.LeadingMarginSpan2; diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java index c03f7a6..3ed37b3 100755 --- a/core/java/android/text/format/DateFormat.java +++ b/core/java/android/text/format/DateFormat.java @@ -23,8 +23,6 @@ import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.SpannedString; -import com.android.internal.R; - import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; diff --git a/core/java/android/text/util/Linkify.java b/core/java/android/text/util/Linkify.java index c1341e1..8e9eb48 100644 --- a/core/java/android/text/util/Linkify.java +++ b/core/java/android/text/util/Linkify.java @@ -78,7 +78,10 @@ public class Linkify { /** * Bit field indicating that street addresses should be matched in methods that - * take an options mask + * take an options mask. Note that this uses the + * {@link android.webkit.WebView#findAddress(String) findAddress()} method in + * {@link android.webkit.WebView} for finding addresses, which has various + * limitations. */ public static final int MAP_ADDRESSES = 0x08; diff --git a/core/java/android/transition/CircularPropagation.java b/core/java/android/transition/CircularPropagation.java index 1e44cfa..c9faa0f 100644 --- a/core/java/android/transition/CircularPropagation.java +++ b/core/java/android/transition/CircularPropagation.java @@ -16,7 +16,6 @@ package android.transition; import android.graphics.Rect; -import android.util.Log; import android.view.View; import android.view.ViewGroup; diff --git a/core/java/android/transition/SidePropagation.java b/core/java/android/transition/SidePropagation.java index 5dd1fff..b10f6a0 100644 --- a/core/java/android/transition/SidePropagation.java +++ b/core/java/android/transition/SidePropagation.java @@ -16,7 +16,6 @@ package android.transition; import android.graphics.Rect; -import android.util.Log; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; diff --git a/core/java/android/transition/TransitionPropagation.java b/core/java/android/transition/TransitionPropagation.java index 9a481c2..b831038 100644 --- a/core/java/android/transition/TransitionPropagation.java +++ b/core/java/android/transition/TransitionPropagation.java @@ -15,7 +15,6 @@ */ package android.transition; -import android.graphics.Rect; import android.view.ViewGroup; /** diff --git a/core/java/android/transition/Visibility.java b/core/java/android/transition/Visibility.java index 26dca43..cd68fd1 100644 --- a/core/java/android/transition/Visibility.java +++ b/core/java/android/transition/Visibility.java @@ -22,9 +22,6 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.content.res.TypedArray; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.drawable.BitmapDrawable; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; diff --git a/core/java/android/util/LocalLog.java b/core/java/android/util/LocalLog.java index e49b8c3..cab5d19 100644 --- a/core/java/android/util/LocalLog.java +++ b/core/java/android/util/LocalLog.java @@ -16,8 +16,6 @@ package android.util; -import android.text.format.Time; - import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.Calendar; diff --git a/core/java/android/view/FrameStats.java b/core/java/android/view/FrameStats.java index b3ac1db..3fbe6fe 100644 --- a/core/java/android/view/FrameStats.java +++ b/core/java/android/view/FrameStats.java @@ -16,9 +16,6 @@ package android.view; -import android.os.Parcel; -import android.os.Parcelable; - /** * This is the base class for frame statistics. */ diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java index 3cb4666..0d36949 100644 --- a/core/java/android/view/GLES20Canvas.java +++ b/core/java/android/view/GLES20Canvas.java @@ -17,19 +17,13 @@ package android.view; import android.graphics.Bitmap; -import android.graphics.Canvas; import android.graphics.CanvasProperty; -import android.graphics.Matrix; import android.graphics.NinePatch; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Picture; import android.graphics.Rect; import android.graphics.RectF; -import android.text.GraphicsOperations; -import android.text.SpannableString; -import android.text.SpannedString; -import android.text.TextUtils; /** * An implementation of Canvas on top of OpenGL ES 2.0. diff --git a/core/java/android/view/GLES20RecordingCanvas.java b/core/java/android/view/GLES20RecordingCanvas.java index 5ca5626..6c780c9 100644 --- a/core/java/android/view/GLES20RecordingCanvas.java +++ b/core/java/android/view/GLES20RecordingCanvas.java @@ -17,7 +17,6 @@ package android.view; import android.annotation.NonNull; -import android.annotation.Nullable; import android.util.Pools.SynchronizedPool; /** diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index aa61885..9921be2 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -19,7 +19,6 @@ package android.view; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Rect; -import android.util.DisplayMetrics; import android.view.Surface.OutOfResourcesException; import java.io.File; diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index 243a0fc..779560c 100644 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -20,7 +20,6 @@ import android.os.Parcel; import android.os.Parcelable; import android.text.method.MetaKeyKeyListener; import android.util.Log; -import android.util.SparseArray; import android.util.SparseIntArray; import android.view.KeyCharacterMap; import android.view.KeyCharacterMap.KeyData; diff --git a/core/java/android/view/MenuInflater.java b/core/java/android/view/MenuInflater.java index 3492aa0..b49a59e 100644 --- a/core/java/android/view/MenuInflater.java +++ b/core/java/android/view/MenuInflater.java @@ -25,8 +25,11 @@ import android.annotation.MenuRes; import android.app.Activity; import android.content.Context; import android.content.ContextWrapper; +import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Log; import android.util.Xml; @@ -334,6 +337,11 @@ public class MenuInflater { private ActionProvider itemActionProvider; + private ColorStateList itemIconTintList; + private boolean itemIconTintListSet; + private PorterDuff.Mode itemIconTintMode; + private boolean itemIconTintModeSet; + private static final int defaultGroupId = NO_ID; private static final int defaultItemId = NO_ID; private static final int defaultItemCategory = 0; @@ -424,6 +432,23 @@ public class MenuInflater { itemActionProvider = null; } + if (a.hasValueOrEmpty(com.android.internal.R.styleable.MenuItem_iconTint)) { + itemIconTintList = a.getColorStateList( + com.android.internal.R.styleable.MenuItem_iconTint); + itemIconTintListSet = true; + } else { + itemIconTintList = null; + itemIconTintListSet = false; + } + if (a.hasValueOrEmpty(com.android.internal.R.styleable.MenuItem_iconTintMode)) { + itemIconTintMode = Drawable.parseTintMode( + a.getInt(com.android.internal.R.styleable.MenuItem_iconTintMode, -1), null); + itemIconTintModeSet = true; + } else { + itemIconTintMode = null; + itemIconTintModeSet = false; + } + a.recycle(); itemAdded = false; @@ -486,6 +511,13 @@ public class MenuInflater { if (itemActionProvider != null) { item.setActionProvider(itemActionProvider); } + + if (itemIconTintListSet) { + item.setIconTintList(itemIconTintList); + } + if (itemIconTintModeSet) { + item.setIconTintMode(itemIconTintMode); + } } public MenuItem addItem() { diff --git a/core/java/android/view/MenuItem.java b/core/java/android/view/MenuItem.java index 9e8b97e..2948007 100644 --- a/core/java/android/view/MenuItem.java +++ b/core/java/android/view/MenuItem.java @@ -21,6 +21,8 @@ import android.annotation.LayoutRes; import android.annotation.StringRes; import android.app.Activity; import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.view.ContextMenu.ContextMenuInfo; import android.view.View.OnCreateContextMenuListener; @@ -599,4 +601,26 @@ public interface MenuItem { * @return This menu item instance for call chaining */ public MenuItem setOnActionExpandListener(OnActionExpandListener listener); + + /** + * Applies a tint to the icon drawable. Does not modify the current tint + * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. + * <p> + * Subsequent calls to {@link android.view.MenuItem#setIcon(android.graphics.drawable.Drawable)} + * will automatically mutate the drawable and apply the specified tint and tint mode. + * + * @param tint the tint to apply, may be {@code null} to clear tint + * @return This menu item instance for call chaining + */ + public MenuItem setIconTintList(ColorStateList tint); + + /** + * Specifies the blending mode used to apply the tint specified by {@link + * #setIconTintList(ColorStateList)} to the icon drawable. The default mode is {@link + * PorterDuff.Mode#SRC_IN}. + * + * @param tintMode the blending mode used to apply the tint, may be {@code null} to clear tint + * @return This menu item instance for call chaining + */ + public MenuItem setIconTintMode(PorterDuff.Mode tintMode); } diff --git a/core/java/android/view/PhoneWindow.java b/core/java/android/view/PhoneWindow.java index 54a0025..d4b14f6 100644 --- a/core/java/android/view/PhoneWindow.java +++ b/core/java/android/view/PhoneWindow.java @@ -1,4 +1,5 @@ /* + * Copyright (C) 2006 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. @@ -75,6 +76,7 @@ import android.util.EventLog; import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; +import android.view.ActionMode.Callback; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.Animation; @@ -2677,28 +2679,38 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { public ActionMode startActionMode(ActionMode.Callback callback) { if (mActionMode != null) { mActionMode.finish(); + mActionMode = null; } - final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); - ActionMode mode = null; + ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); + ActionModeWrapper mode = null; + ActionMode callbackMode = null; if (getCallback() != null && !isDestroyed()) { try { - mode = getCallback().onWindowStartingActionMode(wrappedCallback); + callbackMode = + getCallback().onWindowStartingActionMode(wrappedCallback); + if (callbackMode != null && callbackMode instanceof ActionModeWrapper) { + // If we get an ActionModeWrapper back, we handle its lifecycle. + mode = (ActionModeWrapper) callbackMode; + callbackMode = null; + } } catch (AbstractMethodError ame) { // Older apps might not implement this callback method. } } - if (mode != null) { - mActionMode = mode; + if (callbackMode != null) { + mActionMode = callbackMode; } else { + if (mode == null) { + mode = new ActionModeWrapper( + mContext, wrappedCallback, new StandaloneActionModeProvider()); + } if (mActionModeView != null) { mActionModeView.killMode(); } - ActionModeWrapper wrapperMode = new ActionModeWrapper( - mContext, wrappedCallback, new StandaloneActionModeProvider()); - if (callback.onCreateActionMode(wrapperMode, wrapperMode.getMenu())) { - mActionMode = wrapperMode; - wrapperMode.lockType(); + if (callback.onCreateActionMode(mode, mode.getMenu())) { + mode.lockType(); + mActionMode = mode.getWrappedActionMode(); mActionMode.invalidate(); } else { mActionMode = null; @@ -3309,7 +3321,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } if (getCallback() != null && !isDestroyed()) { try { - getCallback().onActionModeFinished(mActionMode); + getCallback().onActionModeFinished(mode); } catch (AbstractMethodError ame) { // Older apps might not implement this callback method. } @@ -4171,12 +4183,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { return mMediaController; } - private boolean isTranslucent() { - TypedArray a = getWindowStyle(); - return a.getBoolean(a.getResourceId( - R.styleable.Window_windowIsTranslucent, 0), false); - } - @Override public void setEnterTransition(Transition enterTransition) { mEnterTransition = enterTransition; diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 502d5ee..f25b640 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -16,9 +16,7 @@ package android.view; -import android.animation.Animator; import android.animation.AnimatorInflater; -import android.animation.ObjectAnimator; import android.animation.StateListAnimator; import android.annotation.DrawableRes; import android.annotation.IdRes; @@ -34,6 +32,7 @@ import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Insets; +import android.graphics.Interpolator; import android.graphics.LinearGradient; import android.graphics.Matrix; import android.graphics.Outline; @@ -4325,7 +4324,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @hide This is the real method; the public one is shimmed to be safe to call from apps. */ protected void initializeFadingEdgeInternal(TypedArray a) { - getScrollCache().fadingEdgeLength = a.getDimensionPixelSize( + initScrollCache(); + + mScrollCache.fadingEdgeLength = a.getDimensionPixelSize( R.styleable.View_fadingEdgeLength, ViewConfiguration.get(mContext).getScaledFadingEdgeLength()); } @@ -4359,7 +4360,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * content in this view is visible. */ public void setFadingEdgeLength(int length) { - getScrollCache().fadingEdgeLength = length; + initScrollCache(); + mScrollCache.fadingEdgeLength = length; } /** @@ -4463,7 +4465,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @hide */ protected void initializeScrollbarsInternal(TypedArray a) { - final ScrollabilityCache scrollabilityCache = getScrollCache(); + initScrollCache(); + + final ScrollabilityCache scrollabilityCache = mScrollCache; + if (scrollabilityCache.scrollBar == null) { scrollabilityCache.scrollBar = new ScrollBarDrawable(); scrollabilityCache.scrollBar.setCallback(this); @@ -4471,16 +4476,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } final boolean fadeScrollbars = a.getBoolean(R.styleable.View_fadeScrollbars, true); - scrollabilityCache.setFadingEnabled(fadeScrollbars); + + if (!fadeScrollbars) { + scrollabilityCache.state = ScrollabilityCache.ON; + } + scrollabilityCache.fadeScrollBars = fadeScrollbars; + scrollabilityCache.scrollBarFadeDuration = a.getInt( - R.styleable.View_scrollbarFadeDuration, - ViewConfiguration.getScrollBarFadeDuration()); + R.styleable.View_scrollbarFadeDuration, ViewConfiguration + .getScrollBarFadeDuration()); scrollabilityCache.scrollBarDefaultDelayBeforeFade = a.getInt( R.styleable.View_scrollbarDefaultDelayBeforeFade, ViewConfiguration.getScrollDefaultDelay()); + + scrollabilityCache.scrollBarSize = a.getDimensionPixelSize( - R.styleable.View_scrollbarSize, + com.android.internal.R.styleable.View_scrollbarSize, ViewConfiguration.get(mContext).getScaledScrollBarSize()); Drawable track = a.getDrawable(R.styleable.View_scrollbarTrackHorizontal); @@ -4525,12 +4537,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * Returns the scrollability cache, initializing a new cache if necessary. + * <p> + * Initalizes the scrollability cache if necessary. + * </p> */ - private ScrollabilityCache getScrollCache() { + private void initScrollCache() { if (mScrollCache == null) { - mScrollCache = new ScrollabilityCache(this); + mScrollCache = new ScrollabilityCache(ViewConfiguration.get(mContext), this); } + } + + private ScrollabilityCache getScrollCache() { + initScrollCache(); return mScrollCache; } @@ -10047,6 +10065,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @return The measured width of this view as a bit mask. */ + @ViewDebug.ExportedProperty(category = "measurement", flagMapping = { + @ViewDebug.FlagToString(mask = MEASURED_STATE_MASK, equals = MEASURED_STATE_TOO_SMALL, + name = "MEASURED_STATE_TOO_SMALL"), + }) public final int getMeasuredWidthAndState() { return mMeasuredWidth; } @@ -10071,6 +10093,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @return The measured width of this view as a bit mask. */ + @ViewDebug.ExportedProperty(category = "measurement", flagMapping = { + @ViewDebug.FlagToString(mask = MEASURED_STATE_MASK, equals = MEASURED_STATE_TOO_SMALL, + name = "MEASURED_STATE_TOO_SMALL"), + }) public final int getMeasuredHeightAndState() { return mMeasuredHeight; } @@ -11551,30 +11577,31 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see #setVerticalScrollBarEnabled(boolean) */ protected boolean awakenScrollBars() { - return mScrollCache != null - && awakenScrollBars(mScrollCache.scrollBarDefaultDelayBeforeFade, true); + return mScrollCache != null && + awakenScrollBars(mScrollCache.scrollBarDefaultDelayBeforeFade, true); } /** * Trigger the scrollbars to draw. - * <p> * This method differs from awakenScrollBars() only in its default duration. * initialAwakenScrollBars() will show the scroll bars for longer than * usual to give the user more of a chance to notice them. * * @return true if the animation is played, false otherwise. - * @see #awakenScrollBars() */ private boolean initialAwakenScrollBars() { - return mScrollCache != null - && awakenScrollBars(mScrollCache.scrollBarDelayBeforeInitialFade, true); + return mScrollCache != null && + awakenScrollBars(mScrollCache.scrollBarDefaultDelayBeforeFade * 4, true); } /** + * <p> * Trigger the scrollbars to draw. When invoked this method starts an * animation to fade the scrollbars out after a fixed delay. If a subclass * provides animated scrolling, the start delay should equal the duration of * the scrolling animation. + * </p> + * * <p> * The animation starts only if at least one of the scrollbars is enabled, * as specified by {@link #isHorizontalScrollBarEnabled()} and @@ -11582,14 +11609,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * this method returns true, and false otherwise. If the animation is * started, this method calls {@link #invalidate()}; in that case the caller * should not call {@link #invalidate()}. + * </p> + * * <p> * This method should be invoked every time a subclass directly updates the * scroll parameters. + * </p> * - * @param fadeOutDelay the delay in milliseconds before the fade out - * animation should start, or 0 to start the animation - * immediately + * @param startDelay the delay, in milliseconds, after which the animation + * should start; when the delay is 0, the animation starts + * immediately * @return true if the animation is played, false otherwise + * * @see #scrollBy(int, int) * @see #scrollTo(int, int) * @see #isHorizontalScrollBarEnabled() @@ -11597,15 +11628,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see #setHorizontalScrollBarEnabled(boolean) * @see #setVerticalScrollBarEnabled(boolean) */ - protected boolean awakenScrollBars(int fadeOutDelay) { - return awakenScrollBars(fadeOutDelay, true); + protected boolean awakenScrollBars(int startDelay) { + return awakenScrollBars(startDelay, true); } /** + * <p> * Trigger the scrollbars to draw. When invoked this method starts an * animation to fade the scrollbars out after a fixed delay. If a subclass * provides animated scrolling, the start delay should equal the duration of * the scrolling animation. + * </p> + * * <p> * The animation starts only if at least one of the scrollbars is enabled, * as specified by {@link #isHorizontalScrollBarEnabled()} and @@ -11614,18 +11648,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * started, this method calls {@link #invalidate()} if the invalidate parameter * is set to true; in that case the caller * should not call {@link #invalidate()}. + * </p> + * * <p> * This method should be invoked every time a subclass directly updates the * scroll parameters. - * <p> - * <strong>Note:</strong> If the view has not explicitly requested - * scrollbars prior calling this method, this is a no-op. + * </p> + * + * @param startDelay the delay, in milliseconds, after which the animation + * should start; when the delay is 0, the animation starts + * immediately + * + * @param invalidate Whether this method should call invalidate * - * @param fadeOutDelay the delay in milliseconds before the fade out - * animation should start, or 0 to start the animation - * immediately - * @param invalidate whether this method should call invalidate * @return true if the animation is played, false otherwise + * * @see #scrollBy(int, int) * @see #scrollTo(int, int) * @see #isHorizontalScrollBarEnabled() @@ -11633,15 +11670,50 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see #setHorizontalScrollBarEnabled(boolean) * @see #setVerticalScrollBarEnabled(boolean) */ - protected boolean awakenScrollBars(int fadeOutDelay, boolean invalidate) { - if (mScrollCache == null - || (!isHorizontalScrollBarEnabled() && !isVerticalScrollBarEnabled())) { - // We're not supposed to show scroll bars right now. + protected boolean awakenScrollBars(int startDelay, boolean invalidate) { + final ScrollabilityCache scrollCache = mScrollCache; + + if (scrollCache == null || !scrollCache.fadeScrollBars) { return false; } - mScrollCache.awakenScrollBars(fadeOutDelay); - return true; + if (scrollCache.scrollBar == null) { + scrollCache.scrollBar = new ScrollBarDrawable(); + scrollCache.scrollBar.setCallback(this); + scrollCache.scrollBar.setState(getDrawableState()); + } + + if (isHorizontalScrollBarEnabled() || isVerticalScrollBarEnabled()) { + + if (invalidate) { + // Invalidate to show the scrollbars + postInvalidateOnAnimation(); + } + + if (scrollCache.state == ScrollabilityCache.OFF) { + // FIXME: this is copied from WindowManagerService. + // We should get this value from the system when it + // is possible to do so. + final int KEY_REPEAT_FIRST_DELAY = 750; + startDelay = Math.max(KEY_REPEAT_FIRST_DELAY, startDelay); + } + + // Tell mScrollCache when we should start fading. This may + // extend the fade start time if one was already scheduled + long fadeStartTime = AnimationUtils.currentAnimationTimeMillis() + startDelay; + scrollCache.fadeStartTime = fadeStartTime; + scrollCache.state = ScrollabilityCache.ON; + + // Schedule our fader to run, unscheduling any old ones first + if (mAttachInfo != null) { + mAttachInfo.mHandler.removeCallbacks(scrollCache); + mAttachInfo.mHandler.postAtTime(scrollCache, fadeStartTime); + } + + return true; + } + + return false; } /** @@ -12322,7 +12394,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public void setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled) { if (isHorizontalFadingEdgeEnabled() != horizontalFadingEdgeEnabled) { if (horizontalFadingEdgeEnabled) { - getScrollCache(); + initScrollCache(); } mViewFlags ^= FADING_EDGE_HORIZONTAL; @@ -12359,7 +12431,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public void setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled) { if (isVerticalFadingEdgeEnabled() != verticalFadingEdgeEnabled) { if (verticalFadingEdgeEnabled) { - getScrollCache(); + initScrollCache(); } mViewFlags ^= FADING_EDGE_VERTICAL; @@ -12499,7 +12571,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @attr ref android.R.styleable#View_fadeScrollbars */ public void setScrollbarFadingEnabled(boolean fadeScrollbars) { - getScrollCache().setFadingEnabled(fadeScrollbars); + initScrollCache(); + final ScrollabilityCache scrollabilityCache = mScrollCache; + scrollabilityCache.fadeScrollBars = fadeScrollbars; + if (fadeScrollbars) { + scrollabilityCache.state = ScrollabilityCache.OFF; + } else { + scrollabilityCache.state = ScrollabilityCache.ON; + } } /** @@ -12511,7 +12590,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @attr ref android.R.styleable#View_fadeScrollbars */ public boolean isScrollbarFadingEnabled() { - return mScrollCache != null && mScrollCache.isFadingEnabled(); + return mScrollCache != null && mScrollCache.fadeScrollBars; } /** @@ -12793,85 +12872,129 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * Request the drawing of the horizontal and the vertical scrollbar. The - * scrollbars are painted only if they have been awakened first. + * <p>Request the drawing of the horizontal and the vertical scrollbar. The + * scrollbars are painted only if they have been awakened first.</p> * * @param canvas the canvas on which to draw the scrollbars + * * @see #awakenScrollBars(int) */ protected final void onDrawScrollBars(Canvas canvas) { + // scrollbars are drawn only when the animation is running final ScrollabilityCache cache = mScrollCache; - if (cache == null) { - // This view does not currently support scrolling. - return; - } - - final int viewFlags = mViewFlags; - final boolean drawHorizontalScrollBar = - (viewFlags & SCROLLBARS_HORIZONTAL) == SCROLLBARS_HORIZONTAL; - final boolean drawVerticalScrollBar = - (viewFlags & SCROLLBARS_VERTICAL) == SCROLLBARS_VERTICAL - && !isVerticalScrollBarHidden(); - if (!drawVerticalScrollBar && !drawHorizontalScrollBar) { - // This view does not currently draw scrollbars. - return; - } + if (cache != null) { - final ScrollBarDrawable scrollBar = cache.scrollBar; - final int width = mRight - mLeft; - final int height = mBottom - mTop; - final int scrollX = mScrollX; - final int scrollY = mScrollY; - final int inside = (viewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0; + int state = cache.state; - if (drawHorizontalScrollBar) { - int size = scrollBar.getSize(false); - if (size <= 0) { - size = cache.scrollBarSize; + if (state == ScrollabilityCache.OFF) { + return; } - scrollBar.setParameters(computeHorizontalScrollRange(), computeHorizontalScrollOffset(), - computeHorizontalScrollExtent(), false); - final int verticalScrollBarGap = drawVerticalScrollBar ? - getVerticalScrollbarWidth() : 0; + boolean invalidate = false; - final int left = scrollX + (mPaddingLeft & inside); - final int right = scrollX + width - (mUserPaddingRight & inside) - verticalScrollBarGap; - final int top = scrollY + height - size - (mUserPaddingBottom & inside); - final int bottom = top + size; - - onDrawHorizontalScrollBar(canvas, scrollBar, left, top, right, bottom); - } + if (state == ScrollabilityCache.FADING) { + // We're fading -- get our fade interpolation + if (cache.interpolatorValues == null) { + cache.interpolatorValues = new float[1]; + } - if (drawVerticalScrollBar) { - int size = scrollBar.getSize(true); - if (size <= 0) { - size = cache.scrollBarSize; - } + float[] values = cache.interpolatorValues; - scrollBar.setParameters(computeVerticalScrollRange(), computeVerticalScrollOffset(), - computeVerticalScrollExtent(), true); + // Stops the animation if we're done + if (cache.scrollBarInterpolator.timeToValues(values) == + Interpolator.Result.FREEZE_END) { + cache.state = ScrollabilityCache.OFF; + } else { + cache.scrollBar.mutate().setAlpha(Math.round(values[0])); + } - final int verticalScrollbarPosition; - if (mVerticalScrollbarPosition == SCROLLBAR_POSITION_DEFAULT) { - verticalScrollbarPosition = isLayoutRtl() ? - SCROLLBAR_POSITION_LEFT : SCROLLBAR_POSITION_RIGHT; + // This will make the scroll bars inval themselves after + // drawing. We only want this when we're fading so that + // we prevent excessive redraws + invalidate = true; } else { - verticalScrollbarPosition = mVerticalScrollbarPosition; + // We're just on -- but we may have been fading before so + // reset alpha + cache.scrollBar.mutate().setAlpha(255); } - final int left; - if (verticalScrollbarPosition == SCROLLBAR_POSITION_LEFT) { - left = scrollX + (mUserPaddingLeft & inside); - } else { - left = scrollX + width - size - (mUserPaddingRight & inside); - } - final int top = scrollY + (mPaddingTop & inside); - final int right = left + size; - final int bottom = scrollY + height - (mUserPaddingBottom & inside); + final int viewFlags = mViewFlags; + + final boolean drawHorizontalScrollBar = + (viewFlags & SCROLLBARS_HORIZONTAL) == SCROLLBARS_HORIZONTAL; + final boolean drawVerticalScrollBar = + (viewFlags & SCROLLBARS_VERTICAL) == SCROLLBARS_VERTICAL + && !isVerticalScrollBarHidden(); + + if (drawVerticalScrollBar || drawHorizontalScrollBar) { + final int width = mRight - mLeft; + final int height = mBottom - mTop; + + final ScrollBarDrawable scrollBar = cache.scrollBar; + + final int scrollX = mScrollX; + final int scrollY = mScrollY; + final int inside = (viewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0; + + int left; + int top; + int right; + int bottom; - onDrawVerticalScrollBar(canvas, scrollBar, left, top, right, bottom); + if (drawHorizontalScrollBar) { + int size = scrollBar.getSize(false); + if (size <= 0) { + size = cache.scrollBarSize; + } + + scrollBar.setParameters(computeHorizontalScrollRange(), + computeHorizontalScrollOffset(), + computeHorizontalScrollExtent(), false); + final int verticalScrollBarGap = drawVerticalScrollBar ? + getVerticalScrollbarWidth() : 0; + top = scrollY + height - size - (mUserPaddingBottom & inside); + left = scrollX + (mPaddingLeft & inside); + right = scrollX + width - (mUserPaddingRight & inside) - verticalScrollBarGap; + bottom = top + size; + onDrawHorizontalScrollBar(canvas, scrollBar, left, top, right, bottom); + if (invalidate) { + invalidate(left, top, right, bottom); + } + } + + if (drawVerticalScrollBar) { + int size = scrollBar.getSize(true); + if (size <= 0) { + size = cache.scrollBarSize; + } + + scrollBar.setParameters(computeVerticalScrollRange(), + computeVerticalScrollOffset(), + computeVerticalScrollExtent(), true); + int verticalScrollbarPosition = mVerticalScrollbarPosition; + if (verticalScrollbarPosition == SCROLLBAR_POSITION_DEFAULT) { + verticalScrollbarPosition = isLayoutRtl() ? + SCROLLBAR_POSITION_LEFT : SCROLLBAR_POSITION_RIGHT; + } + switch (verticalScrollbarPosition) { + default: + case SCROLLBAR_POSITION_RIGHT: + left = scrollX + width - size - (mUserPaddingRight & inside); + break; + case SCROLLBAR_POSITION_LEFT: + left = scrollX + (mUserPaddingLeft & inside); + break; + } + top = scrollY + (mPaddingTop & inside); + right = left + size; + bottom = scrollY + height - (mUserPaddingBottom & inside); + onDrawVerticalScrollBar(canvas, scrollBar, left, top, right, bottom); + if (invalidate) { + invalidate(left, top, right, bottom); + } + } + } } } @@ -12978,7 +13101,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (isFocused()) { InputMethodManager imm = InputMethodManager.peekInstance(); - imm.focusIn(this); + if (imm != null) { + imm.focusIn(this); + } } } @@ -15235,7 +15360,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, canvas.saveLayer(right - length, top, right, bottom, null, flags); } } else { - scrollabilityCache.setFadingEdgeColor(solidColor); + scrollabilityCache.setFadeColor(solidColor); } // Step 3, draw the content @@ -15245,9 +15370,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, dispatchDraw(canvas); // Step 5, draw the fade effect and restore layers - final Paint p = scrollabilityCache.fadingEdgePaint; + final Paint p = scrollabilityCache.paint; final Matrix matrix = scrollabilityCache.matrix; - final Shader fade = scrollabilityCache.fadingEdgeShader; + final Shader fade = scrollabilityCache.shader; if (drawTop) { matrix.setScale(1, fadeHeight * topFadeStrength); @@ -20507,164 +20632,121 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * ScrollabilityCache holds various fields used by a View when scrolling + * <p>ScrollabilityCache holds various fields used by a View when scrolling * is supported. This avoids keeping too many unused fields in most - * instances of View. + * instances of View.</p> */ - private static class ScrollabilityCache { - public final Paint fadingEdgePaint = new Paint(); - public final Matrix matrix = new Matrix(); - - /** The view that owns this cache. */ - private final View mHost; + private static class ScrollabilityCache implements Runnable { /** - * Minimum delay in milliseconds before the fade-out animation begins. - * Only used if the scrollbar was previously invisible. + * Scrollbars are not visible */ - private static final int MIN_FADE_DELAY_FROM_OFF = 750; + public static final int OFF = 0; /** - * Default delay in milliseconds before the fade-out animation begins. + * Scrollbars are visible */ - public int scrollBarDefaultDelayBeforeFade; + public static final int ON = 1; /** - * Delay in milliseconds before the fade-out animation begins. Only - * used if the scrollbar is being shown to the user for the first time. + * Scrollbars are fading away */ - public int scrollBarDelayBeforeInitialFade; + public static final int FADING = 2; - /** Duration in milliseconds of the fade-out animation. */ - public int scrollBarFadeDuration; + public boolean fadeScrollBars; - public ScrollBarDrawable scrollBar; - public Shader fadingEdgeShader; public int fadingEdgeLength; + public int scrollBarDefaultDelayBeforeFade; + public int scrollBarFadeDuration; + public int scrollBarSize; + public ScrollBarDrawable scrollBar; + public float[] interpolatorValues; + public View host; + + public final Paint paint; + public final Matrix matrix; + public Shader shader; + + public final Interpolator scrollBarInterpolator = new Interpolator(1, 2); + + private static final float[] OPAQUE = { 255 }; + private static final float[] TRANSPARENT = { 0.0f }; /** - * Whether scrollbar fading is enabled. If false, scrollbars are always - * visible. + * When fading should start. This time moves into the future every time + * a new scroll happens. Measured based on SystemClock.uptimeMillis() */ - private boolean mIsFadingEnabled; + public long fadeStartTime; - private Animator mFadeAnim; - private int mFadingEdgeLastColor; - public ScrollabilityCache(View host) { - mHost = host; + /** + * The current state of the scrollbars: ON, OFF, or FADING + */ + public int state = OFF; - scrollBarFadeDuration = ViewConfiguration.getScrollBarFadeDuration(); - scrollBarDefaultDelayBeforeFade = ViewConfiguration.getScrollDefaultDelay(); - scrollBarDelayBeforeInitialFade = ViewConfiguration.getScrollDefaultInitialDelay(); + private int mLastColor; - final ViewConfiguration configuration = ViewConfiguration.get(host.getContext()); - scrollBarSize = configuration.getScaledScrollBarSize(); + public ScrollabilityCache(ViewConfiguration configuration, View host) { fadingEdgeLength = configuration.getScaledFadingEdgeLength(); + scrollBarSize = configuration.getScaledScrollBarSize(); + scrollBarDefaultDelayBeforeFade = ViewConfiguration.getScrollDefaultDelay(); + scrollBarFadeDuration = ViewConfiguration.getScrollBarFadeDuration(); - // Force the fading edge color to change. - mFadingEdgeLastColor = -1; - setFadingEdgeColor(0); + paint = new Paint(); + matrix = new Matrix(); + // use use a height of 1, and then wack the matrix each time we + // actually use it. + shader = new LinearGradient(0, 0, 0, 1, 0xFF000000, 0, Shader.TileMode.CLAMP); + paint.setShader(shader); + paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); + + this.host = host; } - public void setFadingEdgeColor(int color) { - if (mFadingEdgeLastColor != color) { - mFadingEdgeLastColor = color; + public void setFadeColor(int color) { + if (color != mLastColor) { + mLastColor = color; - final int color0; - final int color1; - final PorterDuffXfermode xfermode; if (color != 0) { - color0 = color | 0xFF000000; - color1 = color & 0x00FFFFFF; - xfermode = null; + shader = new LinearGradient(0, 0, 0, 1, color | 0xFF000000, + color & 0x00FFFFFF, Shader.TileMode.CLAMP); + paint.setShader(shader); + // Restore the default transfer mode (src_over) + paint.setXfermode(null); } else { - color0 = 0xFF000000; - color1 = 0; - xfermode = new PorterDuffXfermode(PorterDuff.Mode.DST_OUT); + shader = new LinearGradient(0, 0, 0, 1, 0xFF000000, 0, Shader.TileMode.CLAMP); + paint.setShader(shader); + paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); } - - // Use a height of 1 and then whack the matrix each time we - // actually use it. - fadingEdgeShader = new LinearGradient( - 0, 0, 0, 1, color0, color1, Shader.TileMode.CLAMP); - fadingEdgePaint.setShader(fadingEdgeShader); - fadingEdgePaint.setXfermode(xfermode); } } - public void setFadingEnabled(boolean enabled) { - if (mIsFadingEnabled != enabled) { - mIsFadingEnabled = enabled; + public void run() { + long now = AnimationUtils.currentAnimationTimeMillis(); + if (now >= fadeStartTime) { - setFadingAlpha(enabled ? 0 : 255); - } - } + // the animation fades the scrollbars out by changing + // the opacity (alpha) from fully opaque to fully + // transparent + int nextFrame = (int) now; + int framesCount = 0; - public boolean isFadingEnabled() { - return mIsFadingEnabled; - } + Interpolator interpolator = scrollBarInterpolator; - /** - * Cancels any ongoing or pending fade animations and immediately sets - * the scroll bar alpha value. - * - * @param alpha the scrollbar alpha value - */ - public void setFadingAlpha(int alpha) { - if (mFadeAnim != null) { - mFadeAnim.cancel(); - mFadeAnim = null; - } - mHost.removeCallbacks(mFadeOutRunnable); + // Start opaque + interpolator.setKeyFrame(framesCount++, nextFrame, OPAQUE); - scrollBar.setAlpha(alpha); - } + // End transparent + nextFrame += scrollBarFadeDuration; + interpolator.setKeyFrame(framesCount, nextFrame, TRANSPARENT); - /** - * If fading is enabled, cancels any ongoing or pending fade animations - * and immediately sets the scroll bar alpha value to the maximum, then - * posts a delayed fade-out animation. - * - * @param fadeOutDelay the delay before the fade-out animation starts - * @return {@code true} if the scroll bars changed, false otherwise - */ - public boolean awakenScrollBars(int fadeOutDelay) { - if (!mIsFadingEnabled) { - return false; - } + state = FADING; - if (scrollBar == null) { - scrollBar = new ScrollBarDrawable(); - scrollBar.setCallback(mHost); - scrollBar.setState(mHost.getDrawableState()); + // Kick off the fade animation + host.invalidate(true); } - - // Removes pending callbacks. - setFadingAlpha(255); - - final int startingAlpha = scrollBar.getAlpha(); - if (startingAlpha == 0) { - fadeOutDelay = Math.max(ScrollabilityCache.MIN_FADE_DELAY_FROM_OFF, fadeOutDelay); - } - - mHost.postDelayed(mFadeOutRunnable, fadeOutDelay); - - return true; } - - private final Runnable mFadeOutRunnable = new Runnable() { - @Override - public void run() { - final ObjectAnimator anim = ObjectAnimator.ofInt( - scrollBar, ScrollBarDrawable.ALPHA, 0); - anim.setDuration(scrollBarFadeDuration); - anim.start(); - - mFadeAnim = anim; - } - }; } /** diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index d733513..4e91ad4 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -47,12 +47,6 @@ public class ViewConfiguration { private static final int SCROLL_BAR_DEFAULT_DELAY = 300; /** - * Default delay before the scrollbars fade in milliseconds for the first - * time they are shown to the user. - */ - private static final int SCROLL_BAR_DEFAULT_INITIAL_DELAY = 1500; - - /** * Defines the length of the fading edges in dips */ private static final int FADING_EDGE_LENGTH = 12; @@ -401,23 +395,13 @@ public class ViewConfiguration { } /** - * @return Default delay in milliseconds before the scrollbars fade out - * after they have been awoken. + * @return Default delay before the scrollbars fade in milliseconds */ public static int getScrollDefaultDelay() { return SCROLL_BAR_DEFAULT_DELAY; } /** - * @return Default delay in milliseconds before the scrollbars fade out - * after they are initially shown to the user. - * @hide Pending cleanup of ViewConfiguration values. - */ - public static int getScrollDefaultInitialDelay() { - return SCROLL_BAR_DEFAULT_INITIAL_DELAY; - } - - /** * @return the length of the fading edges in dips * * @deprecated Use {@link #getScaledFadingEdgeLength()} instead. diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index a49d8c3..dfe9f0e 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -53,11 +53,8 @@ import com.android.internal.util.Predicate; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.NoSuchElementException; - import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; /** diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java index b73b9fa..f18b7ac 100644 --- a/core/java/android/view/ViewPropertyAnimator.java +++ b/core/java/android/view/ViewPropertyAnimator.java @@ -19,8 +19,6 @@ package android.view; import android.animation.Animator; import android.animation.ValueAnimator; import android.animation.TimeInterpolator; -import android.os.Build; - import java.util.ArrayList; import java.util.HashMap; import java.util.Set; diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index a5fa5ed..14b867e 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -47,7 +47,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; -import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; diff --git a/core/java/android/view/accessibility/AccessibilityInteractionClient.java b/core/java/android/view/accessibility/AccessibilityInteractionClient.java index cefd34d..db78ec5 100644 --- a/core/java/android/view/accessibility/AccessibilityInteractionClient.java +++ b/core/java/android/view/accessibility/AccessibilityInteractionClient.java @@ -17,7 +17,6 @@ package android.view.accessibility; import android.accessibilityservice.IAccessibilityServiceConnection; -import android.graphics.Point; import android.os.Binder; import android.os.Build; import android.os.Bundle; diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 325ffdd..0996810 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -27,7 +27,6 @@ import com.android.internal.view.InputBindResult; import android.content.Context; import android.graphics.Matrix; import android.graphics.Rect; -import android.graphics.RectF; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; diff --git a/core/java/android/view/inputmethod/InputMethodSubtypeArray.java b/core/java/android/view/inputmethod/InputMethodSubtypeArray.java index 3ff099a..6a748ce 100644 --- a/core/java/android/view/inputmethod/InputMethodSubtypeArray.java +++ b/core/java/android/view/inputmethod/InputMethodSubtypeArray.java @@ -17,15 +17,10 @@ package android.view.inputmethod; import android.os.Parcel; -import android.os.Parcelable; -import android.util.AndroidRuntimeException; import android.util.Slog; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.util.List; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; diff --git a/core/java/android/webkit/CookieSyncManager.java b/core/java/android/webkit/CookieSyncManager.java index d9546ca..eda8d36 100644 --- a/core/java/android/webkit/CookieSyncManager.java +++ b/core/java/android/webkit/CookieSyncManager.java @@ -17,7 +17,6 @@ package android.webkit; import android.content.Context; -import android.util.Log; /** diff --git a/core/java/android/webkit/WebBackForwardList.java b/core/java/android/webkit/WebBackForwardList.java index e671376..6f763dc 100644 --- a/core/java/android/webkit/WebBackForwardList.java +++ b/core/java/android/webkit/WebBackForwardList.java @@ -16,7 +16,6 @@ package android.webkit; -import android.annotation.SystemApi; import java.io.Serializable; /** diff --git a/core/java/android/webkit/WebResourceRequest.java b/core/java/android/webkit/WebResourceRequest.java index 07402b3..0760d2b 100644 --- a/core/java/android/webkit/WebResourceRequest.java +++ b/core/java/android/webkit/WebResourceRequest.java @@ -18,7 +18,6 @@ package android.webkit; import android.net.Uri; -import java.io.InputStream; import java.util.Map; /** diff --git a/core/java/android/webkit/WebSyncManager.java b/core/java/android/webkit/WebSyncManager.java index 402394f..801be12 100644 --- a/core/java/android/webkit/WebSyncManager.java +++ b/core/java/android/webkit/WebSyncManager.java @@ -17,11 +17,6 @@ package android.webkit; import android.content.Context; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.os.Process; -import android.util.Log; /* * @deprecated The WebSyncManager no longer does anything. diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java index 1cc899d..01f9b37 100644 --- a/core/java/android/webkit/WebViewClient.java +++ b/core/java/android/webkit/WebViewClient.java @@ -23,8 +23,6 @@ import android.view.InputEvent; import android.view.KeyEvent; import android.view.ViewRootImpl; -import java.security.Principal; - public class WebViewClient { /** diff --git a/core/java/android/webkit/WebViewDatabase.java b/core/java/android/webkit/WebViewDatabase.java index bfea481..cdff416 100644 --- a/core/java/android/webkit/WebViewDatabase.java +++ b/core/java/android/webkit/WebViewDatabase.java @@ -16,7 +16,6 @@ package android.webkit; -import android.annotation.SystemApi; import android.content.Context; /** diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java index 2aee57b..379a732 100644 --- a/core/java/android/webkit/WebViewProvider.java +++ b/core/java/android/webkit/WebViewProvider.java @@ -24,7 +24,6 @@ import android.graphics.Paint; import android.graphics.Picture; import android.graphics.Rect; import android.graphics.drawable.Drawable; -import android.net.Uri; import android.net.http.SslCertificate; import android.os.Bundle; import android.os.Message; diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 164283d..a6e2952 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -21,7 +21,6 @@ import android.content.Context; import android.content.Intent; import android.content.res.TypedArray; import android.graphics.Canvas; -import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index 79ad6e3..d6f9f78 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -31,7 +31,6 @@ import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.ViewConfiguration; -import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import com.android.internal.R; @@ -403,23 +402,26 @@ public abstract class AbsSeekBar extends ProgressBar { } private void updateThumbAndTrackPos(int w, int h) { + final int paddedHeight = h - mPaddingTop - mPaddingBottom; final Drawable track = getCurrentDrawable(); final Drawable thumb = mThumb; // The max height does not incorporate padding, whereas the height // parameter does. - final int trackHeight = Math.min(mMaxHeight, h - mPaddingTop - mPaddingBottom); + final int trackHeight = Math.min(mMaxHeight, paddedHeight); final int thumbHeight = thumb == null ? 0 : thumb.getIntrinsicHeight(); // Apply offset to whichever item is taller. final int trackOffset; final int thumbOffset; if (thumbHeight > trackHeight) { - trackOffset = (thumbHeight - trackHeight) / 2; - thumbOffset = 0; + final int offsetHeight = (paddedHeight - thumbHeight) / 2; + trackOffset = offsetHeight + (thumbHeight - trackHeight) / 2; + thumbOffset = offsetHeight + 0; } else { - trackOffset = 0; - thumbOffset = (trackHeight - thumbHeight) / 2; + final int offsetHeight = (paddedHeight - trackHeight) / 2; + trackOffset = offsetHeight + 0; + thumbOffset = offsetHeight + (trackHeight - thumbHeight) / 2; } if (track != null) { diff --git a/core/java/android/widget/AbsSpinner.java b/core/java/android/widget/AbsSpinner.java index e432747..1cb7f2a 100644 --- a/core/java/android/widget/AbsSpinner.java +++ b/core/java/android/widget/AbsSpinner.java @@ -28,8 +28,6 @@ import android.util.AttributeSet; import android.util.SparseArray; import android.view.View; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** * An abstract base class for spinner widgets. SDK users will probably not diff --git a/core/java/android/widget/ActionMenuPresenter.java b/core/java/android/widget/ActionMenuPresenter.java index 94827dd..4fadc19 100644 --- a/core/java/android/widget/ActionMenuPresenter.java +++ b/core/java/android/widget/ActionMenuPresenter.java @@ -17,10 +17,10 @@ package android.widget; import android.content.Context; +import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; -import android.graphics.Matrix; -import android.graphics.Rect; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; @@ -55,7 +55,7 @@ public class ActionMenuPresenter extends BaseMenuPresenter implements ActionProvider.SubUiVisibilityListener { private static final String TAG = "ActionMenuPresenter"; - private View mOverflowButton; + private OverflowMenuButton mOverflowButton; private boolean mReserveOverflow; private boolean mReserveOverflowSet; private int mWidthLimit; @@ -79,6 +79,8 @@ public class ActionMenuPresenter extends BaseMenuPresenter private OpenOverflowRunnable mPostedOpenRunnable; private ActionMenuPopupCallback mPopupCallback; + private TintInfo mOverflowTintInfo; + final PopupPresenterCallback mPopupPresenterCallback = new PopupPresenterCallback(); int mOpenSubMenuId; @@ -113,6 +115,7 @@ public class ActionMenuPresenter extends BaseMenuPresenter mOverflowButton = new OverflowMenuButton(mSystemContext); final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); mOverflowButton.measure(spec, spec); + applyOverflowTint(); } width -= mOverflowButton.getMeasuredWidth(); } else { @@ -236,6 +239,7 @@ public class ActionMenuPresenter extends BaseMenuPresenter if (hasOverflow) { if (mOverflowButton == null) { mOverflowButton = new OverflowMenuButton(mSystemContext); + applyOverflowTint(); } ViewGroup parent = (ViewGroup) mOverflowButton.getParent(); if (parent != mMenuView) { @@ -550,6 +554,40 @@ public class ActionMenuPresenter extends BaseMenuPresenter menuView.initialize(mMenu); } + public void setOverflowTintList(ColorStateList tint) { + if (mOverflowTintInfo == null) { + mOverflowTintInfo = new TintInfo(); + } + mOverflowTintInfo.mTintList = tint; + mOverflowTintInfo.mHasTintList = true; + + applyOverflowTint(); + } + + public void setOverflowTintMode(PorterDuff.Mode tintMode) { + if (mOverflowTintInfo == null) { + mOverflowTintInfo = new TintInfo(); + } + mOverflowTintInfo.mTintMode = tintMode; + mOverflowTintInfo.mHasTintMode = true; + + applyOverflowTint(); + } + + private void applyOverflowTint() { + final TintInfo tintInfo = mOverflowTintInfo; + if (tintInfo != null && (tintInfo.mHasTintList || tintInfo.mHasTintMode)) { + if (mOverflowButton != null) { + if (tintInfo.mHasTintList) { + mOverflowButton.setImageTintList(tintInfo.mTintList); + } + if (tintInfo.mHasTintMode) { + mOverflowButton.setImageTintMode(tintInfo.mTintMode); + } + } + } + } + private static class SavedState implements Parcelable { public int openSubMenuId; @@ -774,4 +812,11 @@ public class ActionMenuPresenter extends BaseMenuPresenter return mActionButtonPopup != null ? mActionButtonPopup.getPopup() : null; } } + + private static class TintInfo { + ColorStateList mTintList; + PorterDuff.Mode mTintMode; + boolean mHasTintMode; + boolean mHasTintList; + } } diff --git a/core/java/android/widget/ActionMenuView.java b/core/java/android/widget/ActionMenuView.java index 403e4ac..9d3a5dc 100644 --- a/core/java/android/widget/ActionMenuView.java +++ b/core/java/android/widget/ActionMenuView.java @@ -16,7 +16,9 @@ package android.widget; import android.content.Context; +import android.content.res.ColorStateList; import android.content.res.Configuration; +import android.graphics.PorterDuff; import android.util.AttributeSet; import android.view.ContextThemeWrapper; import android.view.Gravity; @@ -546,6 +548,31 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo mReserveOverflow = reserveOverflow; } + /** + * Applies a tint to the overflow drawable. Does not modify the current tint + * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. + * + * @param tint the tint to apply, may be {@code null} to clear tint + */ + public void setOverflowTintList(ColorStateList tint) { + if (mPresenter != null) { + mPresenter.setOverflowTintList(tint); + } + } + + /** + * Specifies the blending mode used to apply the tint specified by {@link + * #setOverflowTintList(ColorStateList)} to the overflow drawable. + * The default mode is {@link PorterDuff.Mode#SRC_IN}. + * + * @param tintMode the blending mode used to apply the tint, may be {@code null} to clear tint + */ + public void setOverflowTintMode(PorterDuff.Mode tintMode) { + if (mPresenter != null) { + mPresenter.setOverflowTintMode(tintMode); + } + } + @Override protected LayoutParams generateDefaultLayoutParams() { LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java index a242175..932b354 100644 --- a/core/java/android/widget/AdapterViewAnimator.java +++ b/core/java/android/widget/AdapterViewAnimator.java @@ -29,8 +29,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.OnClickHandler; import java.util.ArrayList; diff --git a/core/java/android/widget/AdapterViewFlipper.java b/core/java/android/widget/AdapterViewFlipper.java index 01b6530..a105b40 100644 --- a/core/java/android/widget/AdapterViewFlipper.java +++ b/core/java/android/widget/AdapterViewFlipper.java @@ -26,8 +26,6 @@ import android.os.Message; import android.util.AttributeSet; import android.util.Log; import android.view.RemotableViewMethod; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; /** diff --git a/core/java/android/widget/Button.java b/core/java/android/widget/Button.java index 9b0d0dd..154cc33 100644 --- a/core/java/android/widget/Button.java +++ b/core/java/android/widget/Button.java @@ -18,8 +18,6 @@ package android.widget; import android.content.Context; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java index 47fb8a7..fd1c4b8 100644 --- a/core/java/android/widget/CalendarView.java +++ b/core/java/android/widget/CalendarView.java @@ -24,9 +24,6 @@ import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Log; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; - import com.android.internal.R; import java.text.DateFormat; diff --git a/core/java/android/widget/CheckBox.java b/core/java/android/widget/CheckBox.java index 5a7d585..15bbdd2 100644 --- a/core/java/android/widget/CheckBox.java +++ b/core/java/android/widget/CheckBox.java @@ -18,8 +18,6 @@ package android.widget; import android.content.Context; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java index 84f0ee5..22e079c 100644 --- a/core/java/android/widget/CheckedTextView.java +++ b/core/java/android/widget/CheckedTextView.java @@ -34,10 +34,13 @@ import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; /** - * An extension to TextView that supports the {@link android.widget.Checkable} interface. - * This is useful when used in a {@link android.widget.ListView ListView} where the it's - * {@link android.widget.ListView#setChoiceMode(int) setChoiceMode} has been set to - * something other than {@link android.widget.ListView#CHOICE_MODE_NONE CHOICE_MODE_NONE}. + * An extension to {@link TextView} that supports the {@link Checkable} + * interface and displays. + * <p> + * This is useful when used in a {@link android.widget.ListView ListView} where + * the {@link android.widget.ListView#setChoiceMode(int) setChoiceMode} has + * been set to something other than + * {@link android.widget.ListView#CHOICE_MODE_NONE CHOICE_MODE_NONE}. * * @attr ref android.R.styleable#CheckedTextView_checked * @attr ref android.R.styleable#CheckedTextView_checkMark @@ -116,9 +119,10 @@ public class CheckedTextView extends TextView implements Checkable { } /** - * <p>Changes the checked state of this text view.</p> + * Sets the checked state of this view. * - * @param checked true to check the text, false to uncheck it + * @param checked {@code true} set the state to checked, {@code false} to + * uncheck */ public void setChecked(boolean checked) { if (mChecked != checked) { @@ -129,24 +133,24 @@ public class CheckedTextView extends TextView implements Checkable { } } - /** - * Set the checkmark to a given Drawable, identified by its resourece id. This will be drawn - * when {@link #isChecked()} is true. - * - * @param resid The Drawable to use for the checkmark. + * Sets the check mark to the drawable with the specified resource ID. + * <p> + * When this view is checked, the drawable's state set will include + * {@link android.R.attr#state_checked}. * + * @param resId the resource identifier of drawable to use as the check + * mark + * @attr ref android.R.styleable#CheckedTextView_checkMark * @see #setCheckMarkDrawable(Drawable) * @see #getCheckMarkDrawable() - * - * @attr ref android.R.styleable#CheckedTextView_checkMark */ - public void setCheckMarkDrawable(@DrawableRes int resid) { - if (resid != 0 && resid == mCheckMarkResource) { + public void setCheckMarkDrawable(@DrawableRes int resId) { + if (resId != 0 && resId == mCheckMarkResource) { return; } - mCheckMarkResource = resid; + mCheckMarkResource = resId; Drawable d = null; if (mCheckMarkResource != 0) { @@ -156,14 +160,15 @@ public class CheckedTextView extends TextView implements Checkable { } /** - * Set the checkmark to a given Drawable. This will be drawn when {@link #isChecked()} is true. - * - * @param d The Drawable to use for the checkmark. + * Set the check mark to the specified drawable. + * <p> + * When this view is checked, the drawable's state set will include + * {@link android.R.attr#state_checked}. * + * @param d the drawable to use for the check mark + * @attr ref android.R.styleable#CheckedTextView_checkMark * @see #setCheckMarkDrawable(int) * @see #getCheckMarkDrawable() - * - * @attr ref android.R.styleable#CheckedTextView_checkMark */ public void setCheckMarkDrawable(Drawable d) { if (mCheckMarkDrawable != null) { diff --git a/core/java/android/widget/Chronometer.java b/core/java/android/widget/Chronometer.java index 019d475..a15080e 100644 --- a/core/java/android/widget/Chronometer.java +++ b/core/java/android/widget/Chronometer.java @@ -24,8 +24,6 @@ import android.os.SystemClock; import android.text.format.DateUtils; import android.util.AttributeSet; import android.util.Log; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; import java.util.Formatter; diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index dbf82b6..f2afeeb 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -21,7 +21,6 @@ import android.annotation.Nullable; import android.graphics.PorterDuff; import com.android.internal.R; -import android.annotation.DrawableRes; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; diff --git a/core/java/android/widget/CursorAdapter.java b/core/java/android/widget/CursorAdapter.java index 8e318fd..30c74c0 100644 --- a/core/java/android/widget/CursorAdapter.java +++ b/core/java/android/widget/CursorAdapter.java @@ -24,7 +24,6 @@ import android.database.DataSetObserver; import android.os.Handler; import android.util.Log; import android.view.ContextThemeWrapper; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java index 7c6055a..45998f7 100644 --- a/core/java/android/widget/DatePicker.java +++ b/core/java/android/widget/DatePicker.java @@ -33,7 +33,6 @@ import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.NumberPicker.OnValueChangeListener; diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java index a053901..0e3ec7f 100644..100755 --- a/core/java/android/widget/DatePickerCalendarDelegate.java +++ b/core/java/android/widget/DatePickerCalendarDelegate.java @@ -30,7 +30,6 @@ import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.View; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; @@ -112,8 +111,8 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i mTempDate = getCalendarForLocale(mMaxDate, locale); mCurrentDate = getCalendarForLocale(mCurrentDate, locale); - mMinDate.set(DEFAULT_START_YEAR, 1, 1); - mMaxDate.set(DEFAULT_END_YEAR, 12, 31); + mMinDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1); + mMaxDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31); final Resources res = mDelegator.getResources(); final TypedArray a = mContext.obtainStyledAttributes(attrs, @@ -154,34 +153,23 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i dateLayout.setBackground(a.getDrawable(R.styleable.DatePicker_headerBackground)); - final int headerSelectedTextColor = a.getColor( - R.styleable.DatePicker_headerSelectedTextColor, defaultHighlightColor); final int monthTextAppearanceResId = a.getResourceId( R.styleable.DatePicker_headerMonthTextAppearance, 0); if (monthTextAppearanceResId != 0) { mHeaderMonthTextView.setTextAppearance(context, monthTextAppearanceResId); } - mHeaderMonthTextView.setTextColor(ColorStateList.addFirstIfMissing( - mHeaderMonthTextView.getTextColors(), R.attr.state_selected, - headerSelectedTextColor)); final int dayOfMonthTextAppearanceResId = a.getResourceId( R.styleable.DatePicker_headerDayOfMonthTextAppearance, 0); if (dayOfMonthTextAppearanceResId != 0) { mHeaderDayOfMonthTextView.setTextAppearance(context, dayOfMonthTextAppearanceResId); } - mHeaderDayOfMonthTextView.setTextColor(ColorStateList.addFirstIfMissing( - mHeaderDayOfMonthTextView.getTextColors(), R.attr.state_selected, - headerSelectedTextColor)); final int headerYearTextAppearanceResId = a.getResourceId( R.styleable.DatePicker_headerYearTextAppearance, 0); if (headerYearTextAppearanceResId != 0) { mHeaderYearTextView.setTextAppearance(context, headerYearTextAppearanceResId); } - mHeaderYearTextView.setTextColor(ColorStateList.addFirstIfMissing( - mHeaderYearTextView.getTextColors(), R.attr.state_selected, - headerSelectedTextColor)); mDayPickerView = new DayPickerView(mContext); mDayPickerView.setFirstDayOfWeek(mFirstDayOfWeek); diff --git a/core/java/android/widget/DateTimeView.java b/core/java/android/widget/DateTimeView.java index db17df7..0b5824a 100644 --- a/core/java/android/widget/DateTimeView.java +++ b/core/java/android/widget/DateTimeView.java @@ -21,17 +21,14 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.BroadcastReceiver; import android.database.ContentObserver; -import android.net.Uri; import android.os.Handler; import android.text.format.Time; import android.util.AttributeSet; import android.util.Log; -import android.provider.Settings; import android.widget.TextView; import android.widget.RemoteViews.RemoteView; import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; diff --git a/core/java/android/widget/DigitalClock.java b/core/java/android/widget/DigitalClock.java index b936a5b..9e442f9 100644 --- a/core/java/android/widget/DigitalClock.java +++ b/core/java/android/widget/DigitalClock.java @@ -23,9 +23,6 @@ import android.os.SystemClock; import android.provider.Settings; import android.text.format.DateFormat; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; - import java.util.Calendar; /** diff --git a/core/java/android/widget/EditText.java b/core/java/android/widget/EditText.java index 24cc2d8..d21a5f7 100644 --- a/core/java/android/widget/EditText.java +++ b/core/java/android/widget/EditText.java @@ -25,7 +25,6 @@ import android.text.TextUtils; import android.text.method.ArrowKeyMovementMethod; import android.text.method.MovementMethod; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 1ba11da..f8e207f 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -23,8 +23,6 @@ import android.os.Build; import android.os.Parcel; import android.os.Parcelable; import android.text.InputFilter; -import android.text.SpannableString; - import com.android.internal.util.ArrayUtils; import com.android.internal.util.GrowingArrayUtils; import com.android.internal.view.menu.MenuBuilder; @@ -131,6 +129,7 @@ public class Editor { private final UndoManager mUndoManager = new UndoManager(); private UndoOwner mUndoOwner = mUndoManager.getOwner(UNDO_OWNER_TAG, this); final InputFilter mUndoInputFilter = new UndoInputFilter(this); + boolean mAllowUndo = true; // Cursor Controllers. InsertionPointCursorController mInsertionPointCursorController; @@ -243,20 +242,26 @@ public class Editor { boolean canUndo() { UndoOwner[] owners = { mUndoOwner }; - return mUndoManager.countUndos(owners) > 0; + return mAllowUndo && mUndoManager.countUndos(owners) > 0; } boolean canRedo() { UndoOwner[] owners = { mUndoOwner }; - return mUndoManager.countRedos(owners) > 0; + return mAllowUndo && mUndoManager.countRedos(owners) > 0; } void undo() { + if (!mAllowUndo) { + return; + } UndoOwner[] owners = { mUndoOwner }; mUndoManager.undo(owners, 1); // Undo 1 action. } void redo() { + if (!mAllowUndo) { + return; + } UndoOwner[] owners = { mUndoOwner }; mUndoManager.redo(owners, 1); // Redo 1 action. } @@ -4223,6 +4228,12 @@ public class Editor { Log.d(TAG, "filter: source=" + source + " (" + start + "-" + end + ") " + "dest=" + dest + " (" + dstart + "-" + dend + ")"); } + + if (!mEditor.mAllowUndo) { + if (DEBUG_UNDO) Log.d(TAG, "filter: undo is disabled"); + return null; + } + final UndoManager um = mEditor.mUndoManager; if (um.isInUndo()) { if (DEBUG_UNDO) Log.d(TAG, "filter: skipping, currently performing undo/redo"); diff --git a/core/java/android/widget/ExpandableListView.java b/core/java/android/widget/ExpandableListView.java index 323ddb6..fac36c5 100644 --- a/core/java/android/widget/ExpandableListView.java +++ b/core/java/android/widget/ExpandableListView.java @@ -30,8 +30,6 @@ import android.view.ContextMenu; import android.view.SoundEffectConstants; import android.view.View; import android.view.ContextMenu.ContextMenuInfo; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ExpandableListConnector.PositionMetadata; import java.util.ArrayList; diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java index 57bbc42..e8dc11f 100644 --- a/core/java/android/widget/FrameLayout.java +++ b/core/java/android/widget/FrameLayout.java @@ -30,12 +30,9 @@ import android.graphics.Region; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.Gravity; -import android.view.RemotableViewMethod; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; import com.android.internal.R; diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java index ac19e6d..af5a8bf 100644 --- a/core/java/android/widget/Gallery.java +++ b/core/java/android/widget/Gallery.java @@ -33,7 +33,6 @@ import android.view.SoundEffectConstants; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.Transformation; diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java index 41ddc98..e8fe191 100644 --- a/core/java/android/widget/GridLayout.java +++ b/core/java/android/widget/GridLayout.java @@ -31,8 +31,6 @@ import android.util.Printer; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; import com.android.internal.R; diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index 8b2217c..c6e3dc8 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -31,7 +31,6 @@ import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; import android.view.ViewRootImpl; -import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeProvider; import android.view.accessibility.AccessibilityNodeInfo.CollectionInfo; diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java index b37495f..324c2aa 100644 --- a/core/java/android/widget/HorizontalScrollView.java +++ b/core/java/android/widget/HorizontalScrollView.java @@ -20,7 +20,6 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Rect; -import android.graphics.RectF; import android.os.Build; import android.os.Bundle; import android.os.Parcel; diff --git a/core/java/android/widget/ImageButton.java b/core/java/android/widget/ImageButton.java index 22f9c10..332b158 100644 --- a/core/java/android/widget/ImageButton.java +++ b/core/java/android/widget/ImageButton.java @@ -18,8 +18,6 @@ package android.widget; import android.content.Context; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; /** diff --git a/core/java/android/widget/ImageSwitcher.java b/core/java/android/widget/ImageSwitcher.java index 81636a7..08f21a2 100644 --- a/core/java/android/widget/ImageSwitcher.java +++ b/core/java/android/widget/ImageSwitcher.java @@ -21,8 +21,6 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.net.Uri; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; public class ImageSwitcher extends ViewSwitcher { diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 9831dca..041796b 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -44,7 +44,6 @@ import android.view.RemotableViewMethod; import android.view.View; import android.view.ViewDebug; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; import com.android.internal.R; diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index c0f63d2..f599035 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -28,8 +28,6 @@ import android.view.Gravity; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; import java.lang.annotation.Retention; diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index f9c7faa..ee2c055 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -41,7 +41,6 @@ import android.view.ViewDebug; import android.view.ViewGroup; import android.view.ViewParent; import android.view.ViewRootImpl; -import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.CollectionInfo; import android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo; diff --git a/core/java/android/widget/MediaController.java b/core/java/android/widget/MediaController.java index 0b63843..2375089 100644 --- a/core/java/android/widget/MediaController.java +++ b/core/java/android/widget/MediaController.java @@ -33,8 +33,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.SeekBar.OnSeekBarChangeListener; import java.util.Formatter; diff --git a/core/java/android/widget/MultiAutoCompleteTextView.java b/core/java/android/widget/MultiAutoCompleteTextView.java index c10e581..2152e43 100644 --- a/core/java/android/widget/MultiAutoCompleteTextView.java +++ b/core/java/android/widget/MultiAutoCompleteTextView.java @@ -23,8 +23,6 @@ import android.text.Spanned; import android.text.TextUtils; import android.text.method.QwertyKeyListener; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** * An editable text view, extending {@link AutoCompleteTextView}, that diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index a929f3d..399f4c5 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -160,14 +160,14 @@ public class PopupWindow { private final EpicenterCallback mEpicenterCallback = new EpicenterCallback() { @Override public Rect onGetEpicenter(Transition transition) { - final View anchor = mAnchor.get(); + final View anchor = mAnchor != null ? mAnchor.get() : null; final View decor = mDecorView; if (anchor == null || decor == null) { return null; } final Rect anchorBounds = mAnchorBounds; - final int[] anchorLocation = mAnchor.get().getLocationOnScreen(); + final int[] anchorLocation = anchor.getLocationOnScreen(); final int[] popupLocation = mDecorView.getLocationOnScreen(); // Compute the position of the anchor relative to the popup. @@ -1632,8 +1632,14 @@ public class PopupWindow { * view hierarchy, if necessary. */ private void dismissImmediate(View contentView) { + if (mDecorView == null || mBackgroundView == null) { + throw new RuntimeException("Popup window already dismissed"); + } + try { - mWindowManager.removeViewImmediate(mDecorView); + if (mDecorView.isAttachedToWindow()) { + mWindowManager.removeViewImmediate(mDecorView); + } } finally { mDecorView.removeView(mBackgroundView); mDecorView = null; diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index 03878fc..50d701a 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -28,7 +28,6 @@ import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapShader; import android.graphics.Canvas; -import android.graphics.PorterDuff.Mode; import android.graphics.Rect; import android.graphics.Shader; import android.graphics.drawable.Animatable; @@ -51,7 +50,6 @@ import android.view.View; import android.view.ViewDebug; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; -import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationUtils; @@ -1235,24 +1233,6 @@ public class ProgressBar extends View { } } - private void setDrawableTint(int id, ColorStateList tint, Mode tintMode, boolean fallback) { - Drawable layer = null; - - // We expect a layer drawable, so try to find the target ID. - final Drawable d = mCurrentDrawable; - if (d instanceof LayerDrawable) { - layer = ((LayerDrawable) d).findDrawableByLayerId(id); - } - - if (fallback && layer == null) { - layer = d; - } - - layer.mutate(); - layer.setTintList(tint); - layer.setTintMode(tintMode); - } - private synchronized void doRefreshProgress(int id, int progress, boolean fromUser, boolean callBackToApp) { float scale = mMax > 0 ? (float) progress / (float) mMax : 0; diff --git a/core/java/android/widget/QuickContactBadge.java b/core/java/android/widget/QuickContactBadge.java index 3068de9..25b301f 100644 --- a/core/java/android/widget/QuickContactBadge.java +++ b/core/java/android/widget/QuickContactBadge.java @@ -37,8 +37,6 @@ import android.provider.ContactsContract.RawContacts; import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** * Widget used to show an image with the standard QuickContact badge @@ -52,6 +50,7 @@ public class QuickContactBadge extends ImageView implements OnClickListener { private QueryHandler mQueryHandler; private Drawable mDefaultAvatar; private Bundle mExtras = null; + private String mPrioritizedMimeType; protected String[] mExcludeMimes = null; @@ -126,6 +125,15 @@ public class QuickContactBadge extends ImageView implements OnClickListener { public void setMode(int size) { } + /** + * Set which mimetype should be prioritized in the QuickContacts UI. For example, passing the + * value {@link Email#CONTENT_ITEM_TYPE} can cause emails to be displayed more prominently in + * QuickContacts. + */ + public void setPrioritizedMimeType(String prioritizedMimeType) { + mPrioritizedMimeType = prioritizedMimeType; + } + @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); @@ -287,7 +295,7 @@ public class QuickContactBadge extends ImageView implements OnClickListener { final Bundle extras = (mExtras == null) ? new Bundle() : mExtras; if (mContactUri != null) { QuickContact.showQuickContact(getContext(), QuickContactBadge.this, mContactUri, - QuickContact.MODE_LARGE, mExcludeMimes); + mExcludeMimes, mPrioritizedMimeType); } else if (mContactEmail != null && mQueryHandler != null) { extras.putString(EXTRA_URI_CONTENT, mContactEmail); mQueryHandler.startQuery(TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras, @@ -370,10 +378,10 @@ public class QuickContactBadge extends ImageView implements OnClickListener { mContactUri = lookupUri; onContactUriChanged(); - if (trigger && lookupUri != null) { + if (trigger && mContactUri != null) { // Found contact, so trigger QuickContact - QuickContact.showQuickContact(getContext(), QuickContactBadge.this, lookupUri, - QuickContact.MODE_LARGE, mExcludeMimes); + QuickContact.showQuickContact(getContext(), QuickContactBadge.this, mContactUri, + mExcludeMimes, mPrioritizedMimeType); } else if (createUri != null) { // Prompt user to add this person to contacts final Intent intent = new Intent(Intents.SHOW_OR_CREATE_CONTACT, createUri); diff --git a/core/java/android/widget/RadialTimePickerView.java b/core/java/android/widget/RadialTimePickerView.java index dc4d932..28b4db2 100644 --- a/core/java/android/widget/RadialTimePickerView.java +++ b/core/java/android/widget/RadialTimePickerView.java @@ -157,6 +157,7 @@ public class RadialTimePickerView extends View { private boolean mIsOnInnerCircle; private int mSelectorRadius; + private int mSelectorStroke; private int mSelectorDotRadius; private int mCenterDotRadius; @@ -377,6 +378,7 @@ public class RadialTimePickerView extends View { mPaintBackground.setAntiAlias(true); mSelectorRadius = res.getDimensionPixelSize(R.dimen.timepicker_selector_radius); + mSelectorStroke = res.getDimensionPixelSize(R.dimen.timepicker_selector_stroke); mSelectorDotRadius = res.getDimensionPixelSize(R.dimen.timepicker_selector_dot_radius); mCenterDotRadius = res.getDimensionPixelSize(R.dimen.timepicker_center_dot_radius); @@ -772,6 +774,7 @@ public class RadialTimePickerView extends View { alpha = (int) (mAlphaSelector[index % 2][SELECTOR_LINE].getValue() * alphaMod + 0.5f); paint = mPaintSelector[index % 2][SELECTOR_LINE]; paint.setColor(color); + paint.setStrokeWidth(mSelectorStroke); paint.setAlpha(getMultipliedAlpha(color, alpha)); canvas.drawLine(mXCenter, mYCenter, pointX, pointY, paint); } diff --git a/core/java/android/widget/RadioButton.java b/core/java/android/widget/RadioButton.java index aebc1b6..d44fbd7 100644 --- a/core/java/android/widget/RadioButton.java +++ b/core/java/android/widget/RadioButton.java @@ -18,8 +18,6 @@ package android.widget; import android.content.Context; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java index 6586d11..065feb8 100644 --- a/core/java/android/widget/RadioGroup.java +++ b/core/java/android/widget/RadioGroup.java @@ -24,8 +24,6 @@ import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** diff --git a/core/java/android/widget/RatingBar.java b/core/java/android/widget/RatingBar.java index f18e372..b538334 100644 --- a/core/java/android/widget/RatingBar.java +++ b/core/java/android/widget/RatingBar.java @@ -21,9 +21,6 @@ import android.content.res.TypedArray; import android.graphics.drawable.shapes.RectShape; import android.graphics.drawable.shapes.Shape; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -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 fef56b8..a224f5e 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -37,7 +37,6 @@ import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; @@ -1358,6 +1357,7 @@ public class RelativeLayout extends ViewGroup { * {@link android.widget.RelativeLayout RelativeLayout}, such as * ALIGN_WITH_PARENT_LEFT. * @see #addRule(int, int) + * @see #getRule(int) */ public void addRule(int verb) { mRules[verb] = TRUE; @@ -1378,6 +1378,7 @@ public class RelativeLayout extends ViewGroup { * for true or 0 for false). For verbs that don't refer to another sibling * (for example, ALIGN_WITH_PARENT_BOTTOM) just use -1. * @see #addRule(int) + * @see #getRule(int) */ public void addRule(int verb, int anchor) { mRules[verb] = anchor; @@ -1393,6 +1394,7 @@ public class RelativeLayout extends ViewGroup { * ALIGN_WITH_PARENT_LEFT. * @see #addRule(int) * @see #addRule(int, int) + * @see #getRule(int) */ public void removeRule(int verb) { mRules[verb] = 0; @@ -1400,6 +1402,22 @@ public class RelativeLayout extends ViewGroup { mRulesChanged = true; } + /** + * Returns the layout rule associated with a specific verb. + * + * @param verb one of the verbs defined by {@link RelativeLayout}, such + * as ALIGN_WITH_PARENT_LEFT + * @return the id of another view to use as an anchor, a boolean value + * (represented as {@link RelativeLayout#TRUE} for true + * or 0 for false), or -1 for verbs that don't refer to another + * sibling (for example, ALIGN_WITH_PARENT_BOTTOM) + * @see #addRule(int) + * @see #addRule(int, int) + */ + public int getRule(int verb) { + return mRules[verb]; + } + private boolean hasRelativeRules() { return (mInitialRules[START_OF] != 0 || mInitialRules[END_OF] != 0 || mInitialRules[ALIGN_START] != 0 || mInitialRules[ALIGN_END] != 0 || diff --git a/core/java/android/widget/RemoteViewsAdapter.java b/core/java/android/widget/RemoteViewsAdapter.java index 56bdb9b..349f3f0 100644 --- a/core/java/android/widget/RemoteViewsAdapter.java +++ b/core/java/android/widget/RemoteViewsAdapter.java @@ -26,14 +26,12 @@ import android.Manifest; import android.appwidget.AppWidgetManager; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.RemoteException; -import android.os.UserHandle; import android.util.Log; import android.util.Slog; import android.view.LayoutInflater; diff --git a/core/java/android/widget/ScrollBarDrawable.java b/core/java/android/widget/ScrollBarDrawable.java index 6fd90c3..91d6232 100644 --- a/core/java/android/widget/ScrollBarDrawable.java +++ b/core/java/android/widget/ScrollBarDrawable.java @@ -339,21 +339,21 @@ public class ScrollBarDrawable extends Drawable implements Drawable.Callback { } @Override - public void setColorFilter(ColorFilter cf) { - mColorFilter = cf; + public void setColorFilter(ColorFilter colorFilter) { + mColorFilter = colorFilter; mHasSetColorFilter = true; if (mVerticalTrack != null) { - mVerticalTrack.setColorFilter(cf); + mVerticalTrack.setColorFilter(colorFilter); } if (mVerticalThumb != null) { - mVerticalThumb.setColorFilter(cf); + mVerticalThumb.setColorFilter(colorFilter); } if (mHorizontalTrack != null) { - mHorizontalTrack.setColorFilter(cf); + mHorizontalTrack.setColorFilter(colorFilter); } if (mHorizontalThumb != null) { - mHorizontalThumb.setColorFilter(cf); + mHorizontalThumb.setColorFilter(colorFilter); } } diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index 8846421..bbf120a 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -49,8 +49,6 @@ import android.view.CollapsibleActionView; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView.OnItemClickListener; diff --git a/core/java/android/widget/SeekBar.java b/core/java/android/widget/SeekBar.java index fc070e7..d010122 100644 --- a/core/java/android/widget/SeekBar.java +++ b/core/java/android/widget/SeekBar.java @@ -18,8 +18,6 @@ package android.widget; import android.content.Context; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; diff --git a/core/java/android/widget/SlidingDrawer.java b/core/java/android/widget/SlidingDrawer.java index 272f4b0..9c44236 100644 --- a/core/java/android/widget/SlidingDrawer.java +++ b/core/java/android/widget/SlidingDrawer.java @@ -32,7 +32,6 @@ import android.view.VelocityTracker; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** * SlidingDrawer hides content out of the screen and allows the user to drag a handle diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index f0bc303..3746ec6 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -42,7 +42,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnGlobalLayoutListener; -import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ListPopupWindow.ForwardingListener; import android.widget.PopupWindow.OnDismissListener; diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index 803ba4b..2bd3143 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -41,7 +41,6 @@ import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.LinearInterpolator; import android.widget.RemoteViews.RemoteView; diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java index bf35cf9..110d79b 100644 --- a/core/java/android/widget/TabHost.java +++ b/core/java/android/widget/TabHost.java @@ -33,9 +33,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.Window; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; - 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 f90a0a7..9496e62 100644 --- a/core/java/android/widget/TabWidget.java +++ b/core/java/android/widget/TabWidget.java @@ -19,7 +19,6 @@ package android.widget; import android.R; import android.annotation.DrawableRes; import android.content.Context; -import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Rect; @@ -30,7 +29,6 @@ import android.view.View; import android.view.View.OnFocusChangeListener; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** * diff --git a/core/java/android/widget/TableLayout.java b/core/java/android/widget/TableLayout.java index c825d17..093bdcf 100644 --- a/core/java/android/widget/TableLayout.java +++ b/core/java/android/widget/TableLayout.java @@ -24,9 +24,6 @@ import android.util.AttributeSet; import android.util.SparseBooleanArray; import android.view.View; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; - import java.util.regex.Pattern; /** diff --git a/core/java/android/widget/TableRow.java b/core/java/android/widget/TableRow.java index 72fce3f..faf5b84 100644 --- a/core/java/android/widget/TableRow.java +++ b/core/java/android/widget/TableRow.java @@ -24,8 +24,6 @@ import android.view.Gravity; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** diff --git a/core/java/android/widget/TextSwitcher.java b/core/java/android/widget/TextSwitcher.java index 22822b1..ecd9a8c 100644 --- a/core/java/android/widget/TextSwitcher.java +++ b/core/java/android/widget/TextSwitcher.java @@ -21,8 +21,6 @@ import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** * Specialized {@link android.widget.ViewSwitcher} that contains diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 2d0a9cb..632f5c7 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -1055,6 +1055,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener inputType = a.getInt(attr, EditorInfo.TYPE_NULL); break; + case com.android.internal.R.styleable.TextView_allowUndo: + createEditorIfNeeded(); + mEditor.mAllowUndo = a.getBoolean(attr, true); + break; + case com.android.internal.R.styleable.TextView_imeOptions: createEditorIfNeeded(); mEditor.createInputContentTypeIfNeeded(); diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java index 9df8a21..944b491 100644 --- a/core/java/android/widget/TimePicker.java +++ b/core/java/android/widget/TimePicker.java @@ -24,8 +24,6 @@ import android.content.res.TypedArray; import android.os.Parcelable; import android.util.AttributeSet; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; - import com.android.internal.R; import java.util.Locale; diff --git a/core/java/android/widget/TimePickerClockDelegate.java b/core/java/android/widget/TimePickerClockDelegate.java index ed052af..9fdd718 100644 --- a/core/java/android/widget/TimePickerClockDelegate.java +++ b/core/java/android/widget/TimePickerClockDelegate.java @@ -17,7 +17,6 @@ package android.widget; import android.content.Context; -import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; @@ -34,7 +33,6 @@ import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.View.AccessibilityDelegate; -import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; @@ -132,19 +130,19 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate impl mPmText = amPmStrings[1]; final int layoutResourceId = a.getResourceId(R.styleable.TimePicker_internalLayout, - R.layout.time_picker_holo); + R.layout.time_picker_material); final View mainView = inflater.inflate(layoutResourceId, delegator); mHeaderView = mainView.findViewById(R.id.time_header); mHeaderView.setBackground(a.getDrawable(R.styleable.TimePicker_headerBackground)); // Set up hour/minute labels. - mHourView = (TextView) mHeaderView.findViewById(R.id.hours); + mHourView = (TextView) mainView.findViewById(R.id.hours); mHourView.setOnClickListener(mClickListener); mHourView.setAccessibilityDelegate( new ClickActionDelegate(context, R.string.select_hours)); - mSeparatorView = (TextView) mHeaderView.findViewById(R.id.separator); - mMinuteView = (TextView) mHeaderView.findViewById(R.id.minutes); + mSeparatorView = (TextView) mainView.findViewById(R.id.separator); + mMinuteView = (TextView) mainView.findViewById(R.id.minutes); mMinuteView.setOnClickListener(mClickListener); mMinuteView.setAccessibilityDelegate( new ClickActionDelegate(context, R.string.select_minutes)); @@ -162,17 +160,8 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate impl mHourView.setMinWidth(computeStableWidth(mHourView, 24)); mMinuteView.setMinWidth(computeStableWidth(mMinuteView, 60)); - // TODO: This can be removed once we support themed color state lists. - final int headerSelectedTextColor = a.getColor( - R.styleable.TimePicker_headerSelectedTextColor, - res.getColor(R.color.timepicker_default_selector_color_material)); - mHourView.setTextColor(ColorStateList.addFirstIfMissing(mHourView.getTextColors(), - R.attr.state_selected, headerSelectedTextColor)); - mMinuteView.setTextColor(ColorStateList.addFirstIfMissing(mMinuteView.getTextColors(), - R.attr.state_selected, headerSelectedTextColor)); - // Set up AM/PM labels. - mAmPmLayout = mHeaderView.findViewById(R.id.ampm_layout); + mAmPmLayout = mainView.findViewById(R.id.ampm_layout); mAmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.am_label); mAmLabel.setText(amPmStrings[0]); mAmLabel.setOnClickListener(mClickListener); @@ -304,12 +293,15 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate impl final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mAmPmLayout.getLayoutParams(); - if (isAmPmAtStart) { - params.removeRule(RelativeLayout.RIGHT_OF); - params.addRule(RelativeLayout.LEFT_OF, mHourView.getId()); - } else { - params.removeRule(RelativeLayout.LEFT_OF); - params.addRule(RelativeLayout.RIGHT_OF, mMinuteView.getId()); + if (params.getRule(RelativeLayout.RIGHT_OF) != 0 || + params.getRule(RelativeLayout.LEFT_OF) != 0) { + if (isAmPmAtStart) { + params.removeRule(RelativeLayout.RIGHT_OF); + params.addRule(RelativeLayout.LEFT_OF, mHourView.getId()); + } else { + params.removeRule(RelativeLayout.LEFT_OF); + params.addRule(RelativeLayout.RIGHT_OF, mMinuteView.getId()); + } } mAmPmLayout.setLayoutParams(params); @@ -613,11 +605,11 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate impl private void updateAmPmLabelStates(int amOrPm) { final boolean isAm = amOrPm == AM; mAmLabel.setChecked(isAm); - mAmLabel.setAlpha(isAm ? 1 : mDisabledAlpha); + mAmLabel.setSelected(isAm); final boolean isPm = amOrPm == PM; mPmLabel.setChecked(isPm); - mPmLabel.setAlpha(isPm ? 1 : mDisabledAlpha); + mPmLabel.setSelected(isPm); } /** diff --git a/core/java/android/widget/TimePickerSpinnerDelegate.java b/core/java/android/widget/TimePickerSpinnerDelegate.java index af69110..513c55b 100644 --- a/core/java/android/widget/TimePickerSpinnerDelegate.java +++ b/core/java/android/widget/TimePickerSpinnerDelegate.java @@ -28,12 +28,10 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import com.android.internal.R; -import java.text.DateFormatSymbols; import java.util.Calendar; import java.util.Locale; diff --git a/core/java/android/widget/ToggleButton.java b/core/java/android/widget/ToggleButton.java index 4f8342b..6a8449e 100644 --- a/core/java/android/widget/ToggleButton.java +++ b/core/java/android/widget/ToggleButton.java @@ -21,8 +21,6 @@ import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** * Displays checked/unchecked states as a button diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java index c5325c4..9bc2aab 100644 --- a/core/java/android/widget/Toolbar.java +++ b/core/java/android/widget/Toolbar.java @@ -20,8 +20,9 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActionBar; import android.content.Context; +import android.content.res.ColorStateList; import android.content.res.TypedArray; -import android.graphics.RectF; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; @@ -104,6 +105,9 @@ public class Toolbar extends ViewGroup { private ImageButton mNavButtonView; private ImageView mLogoView; + private TintInfo mOverflowTintInfo; + private TintInfo mNavTintInfo; + private Drawable mCollapseIcon; private CharSequence mCollapseDescription; private ImageButton mCollapseButtonView; @@ -266,6 +270,21 @@ public class Toolbar extends ViewGroup { if (!TextUtils.isEmpty(navDesc)) { setNavigationContentDescription(navDesc); } + + if (a.hasValue(R.styleable.Toolbar_overflowTint)) { + setOverflowTintList(a.getColorStateList(R.styleable.Toolbar_overflowTint)); + } + if (a.hasValue(R.styleable.Toolbar_overflowTintMode)) { + setOverflowTintMode(Drawable.parseTintMode( + a.getInt(R.styleable.Toolbar_overflowTintMode, -1), null)); + } + if (a.hasValue(R.styleable.Toolbar_navigationTint)) { + setNavigationTintList(a.getColorStateList(R.styleable.Toolbar_navigationTint)); + } + if (a.hasValue(R.styleable.Toolbar_navigationTintMode)) { + setNavigationTintMode(Drawable.parseTintMode( + a.getInt(R.styleable.Toolbar_navigationTintMode, -1), null)); + } a.recycle(); } @@ -806,6 +825,91 @@ public class Toolbar extends ViewGroup { } /** + * Applies a tint to the icon drawable. Does not modify the current tint + * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. + * <p> + * Subsequent calls to {@link #setNavigationIcon(Drawable)} will automatically mutate + * the drawable and apply the specified tint and tint mode. + * + * @param tint the tint to apply, may be {@code null} to clear tint + * + * @attr ref android.R.styleable#Toolbar_navigationTint + */ + public void setNavigationTintList(ColorStateList tint) { + if (mNavTintInfo == null) { + mNavTintInfo = new TintInfo(); + } + mNavTintInfo.mTintList = tint; + mNavTintInfo.mHasTintList = true; + + applyNavigationTint(); + } + + /** + * Specifies the blending mode used to apply the tint specified by {@link + * #setNavigationTintList(ColorStateList)} to the navigation drawable. + * The default mode is {@link PorterDuff.Mode#SRC_IN}. + * + * @param tintMode the blending mode used to apply the tint, may be {@code null} to clear tint + * + * @attr ref android.R.styleable#Toolbar_navigationTintMode + */ + public void setNavigationTintMode(PorterDuff.Mode tintMode) { + if (mNavTintInfo == null) { + mNavTintInfo = new TintInfo(); + } + mNavTintInfo.mTintMode = tintMode; + mNavTintInfo.mHasTintMode = true; + + applyNavigationTint(); + } + + /** + * Applies a tint to the overflow drawable. Does not modify the current tint + * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. + * + * @param tint the tint to apply, may be {@code null} to clear tint + * + * @attr ref android.R.styleable#Toolbar_overflowTint + */ + public void setOverflowTintList(ColorStateList tint) { + if (mMenuView != null) { + // If the menu view is available, directly set the tint + mMenuView.setOverflowTintList(tint); + } else { + // Otherwise we will record the value + if (mOverflowTintInfo == null) { + mOverflowTintInfo = new TintInfo(); + } + mOverflowTintInfo.mTintList = tint; + mOverflowTintInfo.mHasTintList = true; + } + } + + /** + * Specifies the blending mode used to apply the tint specified by {@link + * #setOverflowTintList(ColorStateList)} to the overflow drawable. + * The default mode is {@link PorterDuff.Mode#SRC_IN}. + * + * @param tintMode the blending mode used to apply the tint, may be {@code null} to clear tint + * + * @attr ref android.R.styleable#Toolbar_overflowTintMode + */ + public void setOverflowTintMode(PorterDuff.Mode tintMode) { + if (mMenuView != null) { + // If the menu view is available, directly set the tint mode + mMenuView.setOverflowTintMode(tintMode); + } else { + // Otherwise we will record the value + if (mOverflowTintInfo == null) { + mOverflowTintInfo = new TintInfo(); + } + mOverflowTintInfo.mTintMode = tintMode; + mOverflowTintInfo.mHasTintMode = true; + } + } + + /** * Return the Menu shown in the toolbar. * * <p>Applications that wish to populate the toolbar's menu can do so from here. To use @@ -841,6 +945,17 @@ public class Toolbar extends ViewGroup { lp.gravity = Gravity.END | (mButtonGravity & Gravity.VERTICAL_GRAVITY_MASK); mMenuView.setLayoutParams(lp); addSystemView(mMenuView); + + if (mOverflowTintInfo != null) { + // If we have tint info for the overflow, set it on the menu view now + if (mOverflowTintInfo.mHasTintList) { + mMenuView.setOverflowTintList(mOverflowTintInfo.mTintList); + } + if (mOverflowTintInfo.mHasTintMode) { + mMenuView.setOverflowTintMode(mOverflowTintInfo.mTintMode); + } + mOverflowTintInfo = null; + } } } @@ -994,6 +1109,7 @@ public class Toolbar extends ViewGroup { final LayoutParams lp = generateDefaultLayoutParams(); lp.gravity = Gravity.START | (mButtonGravity & Gravity.VERTICAL_GRAVITY_MASK); mNavButtonView.setLayoutParams(lp); + applyNavigationTint(); } } @@ -1012,6 +1128,7 @@ public class Toolbar extends ViewGroup { collapseActionView(); } }); + applyNavigationTint(); } } @@ -1763,6 +1880,30 @@ public class Toolbar extends ViewGroup { return mPopupContext; } + private void applyNavigationTint() { + final TintInfo tintInfo = mNavTintInfo; + if (tintInfo != null && (tintInfo.mHasTintList || tintInfo.mHasTintMode)) { + if (mNavButtonView != null) { + if (tintInfo.mHasTintList) { + mNavButtonView.setImageTintList(tintInfo.mTintList); + } + if (tintInfo.mHasTintMode) { + mNavButtonView.setImageTintMode(tintInfo.mTintMode); + } + } + + if (mCollapseButtonView != null) { + // We will use the same tint for the collapse button + if (tintInfo.mHasTintList) { + mCollapseButtonView.setImageTintList(tintInfo.mTintList); + } + if (tintInfo.mHasTintMode) { + mCollapseButtonView.setImageTintMode(tintInfo.mTintMode); + } + } + } + } + /** * Interface responsible for receiving menu item click events if the items themselves * do not have individual item click listeners. @@ -1990,4 +2131,11 @@ public class Toolbar extends ViewGroup { public void onRestoreInstanceState(Parcelable state) { } } + + private static class TintInfo { + ColorStateList mTintList; + PorterDuff.Mode mTintMode; + boolean mHasTintMode; + boolean mHasTintList; + } } diff --git a/core/java/android/widget/TwoLineListItem.java b/core/java/android/widget/TwoLineListItem.java index 0cd7eb9..69ff488 100644 --- a/core/java/android/widget/TwoLineListItem.java +++ b/core/java/android/widget/TwoLineListItem.java @@ -20,8 +20,6 @@ import android.annotation.Widget; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RelativeLayout; /** diff --git a/core/java/android/widget/VideoView.java b/core/java/android/widget/VideoView.java index 48283d4..9d6ba57 100644 --- a/core/java/android/widget/VideoView.java +++ b/core/java/android/widget/VideoView.java @@ -43,8 +43,6 @@ import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.MediaController.MediaPlayerControl; import java.io.IOException; diff --git a/core/java/android/widget/ViewAnimator.java b/core/java/android/widget/ViewAnimator.java index 5ef5222..f30fdd8 100644 --- a/core/java/android/widget/ViewAnimator.java +++ b/core/java/android/widget/ViewAnimator.java @@ -22,8 +22,6 @@ import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.Animation; import android.view.animation.AnimationUtils; diff --git a/core/java/android/widget/ViewFlipper.java b/core/java/android/widget/ViewFlipper.java index a43a185..94e7ba1 100644 --- a/core/java/android/widget/ViewFlipper.java +++ b/core/java/android/widget/ViewFlipper.java @@ -24,8 +24,6 @@ import android.content.res.TypedArray; import android.os.*; import android.util.AttributeSet; import android.util.Log; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; /** diff --git a/core/java/android/widget/ViewSwitcher.java b/core/java/android/widget/ViewSwitcher.java index 2f544cc..0d5627e 100644 --- a/core/java/android/widget/ViewSwitcher.java +++ b/core/java/android/widget/ViewSwitcher.java @@ -20,8 +20,6 @@ import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** * {@link ViewAnimator} that switches between two views, and has a factory diff --git a/core/java/android/widget/ZoomButton.java b/core/java/android/widget/ZoomButton.java index 6b3faed..0255bdb 100644 --- a/core/java/android/widget/ZoomButton.java +++ b/core/java/android/widget/ZoomButton.java @@ -23,8 +23,6 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.View.OnLongClickListener; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; public class ZoomButton extends ImageButton implements OnLongClickListener { diff --git a/core/java/android/widget/ZoomControls.java b/core/java/android/widget/ZoomControls.java index bef1ace..66c052b 100644 --- a/core/java/android/widget/ZoomControls.java +++ b/core/java/android/widget/ZoomControls.java @@ -22,8 +22,6 @@ import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.AlphaAnimation; import com.android.internal.R; diff --git a/core/java/android/alsa/AlsaCardsParser.java b/core/java/com/android/internal/alsa/AlsaCardsParser.java index 5e88bca..5c0a888 100644 --- a/core/java/android/alsa/AlsaCardsParser.java +++ b/core/java/com/android/internal/alsa/AlsaCardsParser.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.alsa; +package com.android.internal.alsa; import android.util.Slog; import java.io.BufferedReader; diff --git a/core/java/android/alsa/AlsaDevicesParser.java b/core/java/com/android/internal/alsa/AlsaDevicesParser.java index b140d3d..81b7943 100644 --- a/core/java/android/alsa/AlsaDevicesParser.java +++ b/core/java/com/android/internal/alsa/AlsaDevicesParser.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.alsa; +package com.android.internal.alsa; import android.util.Slog; import java.io.BufferedReader; diff --git a/core/java/android/alsa/LineTokenizer.java b/core/java/com/android/internal/alsa/LineTokenizer.java index 78c91b5..43047a9 100644 --- a/core/java/android/alsa/LineTokenizer.java +++ b/core/java/com/android/internal/alsa/LineTokenizer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.alsa; +package com.android.internal.alsa; /** * @hide diff --git a/core/java/com/android/internal/app/AlertActivity.java b/core/java/com/android/internal/app/AlertActivity.java index 5566aa6..ed48b0d 100644 --- a/core/java/com/android/internal/app/AlertActivity.java +++ b/core/java/com/android/internal/app/AlertActivity.java @@ -17,11 +17,9 @@ package com.android.internal.app; import android.app.Activity; -import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; -import android.text.TextUtils; import android.view.KeyEvent; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; diff --git a/core/java/com/android/internal/app/AlertController.java b/core/java/com/android/internal/app/AlertController.java index 20d209f..9dabb4e 100644 --- a/core/java/com/android/internal/app/AlertController.java +++ b/core/java/com/android/internal/app/AlertController.java @@ -20,6 +20,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import com.android.internal.R; +import android.annotation.Nullable; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; @@ -38,7 +39,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.ViewParent; -import android.view.ViewTreeObserver; +import android.view.ViewStub; import android.view.Window; import android.view.WindowInsets; import android.view.WindowManager; @@ -450,27 +451,107 @@ public class AlertController { } } + /** + * Resolves whether a custom or default panel should be used. Removes the + * default panel if a custom panel should be used. If the resolved panel is + * a view stub, inflates before returning. + * + * @param customPanel the custom panel + * @param defaultPanel the default panel + * @return the panel to use + */ + @Nullable + private ViewGroup resolvePanel(@Nullable View customPanel, @Nullable View defaultPanel) { + if (customPanel == null) { + // Inflate the default panel, if needed. + if (defaultPanel instanceof ViewStub) { + defaultPanel = ((ViewStub) defaultPanel).inflate(); + } + + return (ViewGroup) defaultPanel; + } + + // Remove the default panel entirely. + if (defaultPanel != null) { + final ViewParent parent = defaultPanel.getParent(); + if (parent instanceof ViewGroup) { + ((ViewGroup) parent).removeView(defaultPanel); + } + } + + // Inflate the custom panel, if needed. + if (customPanel instanceof ViewStub) { + customPanel = ((ViewStub) customPanel).inflate(); + } + + return (ViewGroup) customPanel; + } + private void setupView() { - final ViewGroup contentPanel = (ViewGroup) mWindow.findViewById(R.id.contentPanel); - setupContent(contentPanel); - final boolean hasButtons = setupButtons(); + final View parentPanel = mWindow.findViewById(R.id.parentPanel); + final View defaultTopPanel = parentPanel.findViewById(R.id.topPanel); + final View defaultContentPanel = parentPanel.findViewById(R.id.contentPanel); + final View defaultButtonPanel = parentPanel.findViewById(R.id.buttonPanel); - final ViewGroup topPanel = (ViewGroup) mWindow.findViewById(R.id.topPanel); - final TypedArray a = mContext.obtainStyledAttributes( - null, R.styleable.AlertDialog, R.attr.alertDialogStyle, 0); - final boolean hasTitle = setupTitle(topPanel); + // Install custom content before setting up the title or buttons so + // that we can handle panel overrides. + final ViewGroup customPanel = (ViewGroup) parentPanel.findViewById(R.id.customPanel); + setupCustomContent(customPanel); - final View buttonPanel = mWindow.findViewById(R.id.buttonPanel); - if (!hasButtons) { - buttonPanel.setVisibility(View.GONE); - final View spacer = mWindow.findViewById(R.id.textSpacerNoButtons); - if (spacer != null) { - spacer.setVisibility(View.VISIBLE); + final View customTopPanel = customPanel.findViewById(R.id.topPanel); + final View customContentPanel = customPanel.findViewById(R.id.contentPanel); + final View customButtonPanel = customPanel.findViewById(R.id.buttonPanel); + + // Resolve the correct panels and remove the defaults, if needed. + final ViewGroup topPanel = resolvePanel(customTopPanel, defaultTopPanel); + final ViewGroup contentPanel = resolvePanel(customContentPanel, defaultContentPanel); + final ViewGroup buttonPanel = resolvePanel(customButtonPanel, defaultButtonPanel); + + setupContent(contentPanel); + setupButtons(buttonPanel); + setupTitle(topPanel); + + final boolean hasCustomPanel = customPanel != null + && customPanel.getVisibility() != View.GONE; + final boolean hasTopPanel = topPanel != null + && topPanel.getVisibility() != View.GONE; + final boolean hasButtonPanel = buttonPanel != null + && buttonPanel.getVisibility() != View.GONE; + + // Only display the text spacer if we don't have buttons. + if (!hasButtonPanel) { + if (contentPanel != null) { + final View spacer = contentPanel.findViewById(R.id.textSpacerNoButtons); + if (spacer != null) { + spacer.setVisibility(View.VISIBLE); + } } mWindow.setCloseOnTouchOutsideIfNotSet(true); } - final FrameLayout customPanel = (FrameLayout) mWindow.findViewById(R.id.customPanel); + // Only display the divider if we have a title and a custom view or a + // message. + if (hasTopPanel) { + final View divider; + if (mMessage != null || hasCustomPanel || mListView != null) { + divider = topPanel.findViewById(R.id.titleDivider); + } else { + divider = topPanel.findViewById(R.id.titleDividerTop); + } + + if (divider != null) { + divider.setVisibility(View.VISIBLE); + } + } + + final TypedArray a = mContext.obtainStyledAttributes( + null, R.styleable.AlertDialog, R.attr.alertDialogStyle, 0); + setBackground(a, topPanel, contentPanel, customPanel, buttonPanel, + hasTopPanel, hasCustomPanel, hasButtonPanel); + a.recycle(); + } + + private void setupCustomContent(ViewGroup customPanel) { final View customView; if (mView != null) { customView = mView; @@ -502,30 +583,9 @@ public class AlertController { } else { customPanel.setVisibility(View.GONE); } - - // Only display the divider if we have a title and a custom view or a - // message. - if (hasTitle) { - final View divider; - if (mMessage != null || customView != null || mListView != null) { - divider = mWindow.findViewById(R.id.titleDivider); - } else { - divider = mWindow.findViewById(R.id.titleDividerTop); - } - - if (divider != null) { - divider.setVisibility(View.VISIBLE); - } - } - - setBackground(a, topPanel, contentPanel, customPanel, buttonPanel, hasTitle, hasCustomView, - hasButtons); - a.recycle(); } - private boolean setupTitle(ViewGroup topPanel) { - boolean hasTitle = true; - + private void setupTitle(ViewGroup topPanel) { if (mCustomTitleView != null) { // Add the custom title view directly to the topPanel layout LayoutParams lp = new LayoutParams( @@ -567,18 +627,16 @@ public class AlertController { titleTemplate.setVisibility(View.GONE); mIconView.setVisibility(View.GONE); topPanel.setVisibility(View.GONE); - hasTitle = false; } } - return hasTitle; } private void setupContent(ViewGroup contentPanel) { - mScrollView = (ScrollView) mWindow.findViewById(R.id.scrollView); + mScrollView = (ScrollView) contentPanel.findViewById(R.id.scrollView); mScrollView.setFocusable(false); // Special case for users that only want to display a String - mMessageView = (TextView) mWindow.findViewById(R.id.message); + mMessageView = (TextView) contentPanel.findViewById(R.id.message); if (mMessageView == null) { return; } @@ -601,8 +659,8 @@ public class AlertController { } // Set up scroll indicators (if present). - final View indicatorUp = mWindow.findViewById(R.id.scrollIndicatorUp); - final View indicatorDown = mWindow.findViewById(R.id.scrollIndicatorDown); + final View indicatorUp = contentPanel.findViewById(R.id.scrollIndicatorUp); + final View indicatorDown = contentPanel.findViewById(R.id.scrollIndicatorDown); if (indicatorUp != null || indicatorDown != null) { if (mMessage != null) { // We're just showing the ScrollView, set up listener. @@ -663,12 +721,12 @@ public class AlertController { } } - private boolean setupButtons() { + private void setupButtons(ViewGroup buttonPanel) { int BIT_BUTTON_POSITIVE = 1; int BIT_BUTTON_NEGATIVE = 2; int BIT_BUTTON_NEUTRAL = 4; int whichButtons = 0; - mButtonPositive = (Button) mWindow.findViewById(R.id.button1); + mButtonPositive = (Button) buttonPanel.findViewById(R.id.button1); mButtonPositive.setOnClickListener(mButtonHandler); if (TextUtils.isEmpty(mButtonPositiveText)) { @@ -679,7 +737,7 @@ public class AlertController { whichButtons = whichButtons | BIT_BUTTON_POSITIVE; } - mButtonNegative = (Button) mWindow.findViewById(R.id.button2); + mButtonNegative = (Button) buttonPanel.findViewById(R.id.button2); mButtonNegative.setOnClickListener(mButtonHandler); if (TextUtils.isEmpty(mButtonNegativeText)) { @@ -691,7 +749,7 @@ public class AlertController { whichButtons = whichButtons | BIT_BUTTON_NEGATIVE; } - mButtonNeutral = (Button) mWindow.findViewById(R.id.button3); + mButtonNeutral = (Button) buttonPanel.findViewById(R.id.button3); mButtonNeutral.setOnClickListener(mButtonHandler); if (TextUtils.isEmpty(mButtonNeutralText)) { @@ -717,7 +775,10 @@ public class AlertController { } } - return whichButtons != 0; + final boolean hasButtons = whichButtons != 0; + if (!hasButtons) { + buttonPanel.setVisibility(View.GONE); + } } private void centerButton(Button button) { diff --git a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl index 6d90420..8f549a6 100644 --- a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +++ b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl @@ -26,9 +26,11 @@ import android.service.voice.IVoiceInteractionService; import android.service.voice.IVoiceInteractionSession; interface IVoiceInteractionManagerService { - void startSession(IVoiceInteractionService service, in Bundle sessionArgs, int flags); + void showSession(IVoiceInteractionService service, in Bundle sessionArgs, int flags); boolean deliverNewSession(IBinder token, IVoiceInteractionSession session, IVoiceInteractor interactor); + boolean showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags); + boolean hideSessionFromSession(IBinder token); int startVoiceActivity(IBinder token, in Intent intent, String resolvedType); void finish(IBinder token); diff --git a/core/java/com/android/internal/app/IntentForwarderActivity.java b/core/java/com/android/internal/app/IntentForwarderActivity.java index 7c1308f..f598828 100644 --- a/core/java/com/android/internal/app/IntentForwarderActivity.java +++ b/core/java/com/android/internal/app/IntentForwarderActivity.java @@ -28,7 +28,6 @@ import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.UserInfo; import android.os.Bundle; -import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; diff --git a/core/java/com/android/internal/app/WindowDecorActionBar.java b/core/java/com/android/internal/app/WindowDecorActionBar.java index 061b535..70a0b6b 100644 --- a/core/java/com/android/internal/app/WindowDecorActionBar.java +++ b/core/java/com/android/internal/app/WindowDecorActionBar.java @@ -20,8 +20,10 @@ import android.animation.ValueAnimator; import android.content.res.TypedArray; import android.view.ViewParent; import android.widget.Toolbar; + import com.android.internal.R; import com.android.internal.view.ActionBarPolicy; +import com.android.internal.view.ActionModeWrapper; import com.android.internal.view.menu.MenuBuilder; import com.android.internal.view.menu.MenuPopupHelper; import com.android.internal.view.menu.SubMenuBuilder; @@ -46,6 +48,7 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.util.TypedValue; import android.view.ActionMode; +import android.view.ActionMode.Callback; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.Menu; @@ -88,20 +91,20 @@ public class WindowDecorActionBar extends ActionBar implements private TabImpl mSelectedTab; private int mSavedTabPosition = INVALID_POSITION; - + private boolean mDisplayHomeAsUpSet; - ActionModeImpl mActionMode; + ActionMode mActionMode; ActionMode mDeferredDestroyActionMode; ActionMode.Callback mDeferredModeDestroyCallback; - + private boolean mLastMenuVisibility; private ArrayList<OnMenuVisibilityListener> mMenuVisibilityListeners = new ArrayList<OnMenuVisibilityListener>(); private static final int CONTEXT_DISPLAY_NORMAL = 0; private static final int CONTEXT_DISPLAY_SPLIT = 1; - + private static final int INVALID_POSITION = -1; private int mContextDisplayMode; @@ -490,15 +493,21 @@ public class WindowDecorActionBar extends ActionBar implements } public ActionMode startActionMode(ActionMode.Callback callback) { - if (mActionMode != null) { - mActionMode.finish(); - } + return new ActionModeWrapper(mContext, callback, new ActionModeProviderImpl()); + } + + private class ActionModeProviderImpl implements ActionModeWrapper.ActionModeProvider { - mOverlayLayout.setHideOnContentScrollEnabled(false); - mContextView.killMode(); - ActionModeImpl mode = new ActionModeImpl(mContextView.getContext(), callback); - if (mode.dispatchOnCreate()) { - mode.invalidate(); + @Override + public ActionMode createActionMode(Callback callback, MenuBuilder menuBuilder) { + if (mActionMode != null) { + mActionMode.finish(); + } + + mOverlayLayout.setHideOnContentScrollEnabled(false); + mContextView.killMode(); + ActionModeImpl mode = new ActionModeImpl( + mContextView.getContext(), callback, menuBuilder); mContextView.initForMode(mode); animateToMode(true); if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { @@ -514,7 +523,6 @@ public class WindowDecorActionBar extends ActionBar implements mActionMode = mode; return mode; } - return null; } private void configureTab(Tab tab, int position) { @@ -942,11 +950,14 @@ public class WindowDecorActionBar extends ActionBar implements private ActionMode.Callback mCallback; private WeakReference<View> mCustomView; - public ActionModeImpl(Context context, ActionMode.Callback callback) { + public ActionModeImpl( + Context context, ActionMode.Callback callback, MenuBuilder menuBuilder) { mActionModeContext = context; mCallback = callback; - mMenu = new MenuBuilder(context) - .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + mMenu = menuBuilder == null + ? new MenuBuilder(context) + .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM) + : menuBuilder; mMenu.setCallback(this); } @@ -1008,15 +1019,6 @@ public class WindowDecorActionBar extends ActionBar implements } } - public boolean dispatchOnCreate() { - mMenu.stopDispatchingItemsChanged(); - try { - return mCallback.onCreateActionMode(this, mMenu); - } finally { - mMenu.startDispatchingItemsChanged(); - } - } - @Override public void setCustomView(View view) { mContextView.setCustomView(view); diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java index 044383e..c3cc60a 100644 --- a/core/java/com/android/internal/backup/LocalTransport.java +++ b/core/java/com/android/internal/backup/LocalTransport.java @@ -44,11 +44,8 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashSet; -import java.util.List; - import static android.system.OsConstants.*; /** diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index a55fe9a..5fc5b58 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -30,7 +30,6 @@ import android.os.SystemProperties; import android.system.ErrnoException; import android.system.Os; import android.util.Log; -import dalvik.system.PathClassLoader; import dalvik.system.VMRuntime; import java.io.BufferedReader; import java.io.DataInputStream; diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 400ea37..49d565d 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -24,8 +24,6 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.net.LocalServerSocket; import android.opengl.EGL14; -import android.os.Build; -import android.os.Debug; import android.os.Process; import android.os.SystemClock; import android.os.SystemProperties; @@ -36,7 +34,6 @@ import android.system.OsConstants; import android.system.StructPollfd; import android.util.EventLog; import android.util.Log; -import android.util.Slog; import android.webkit.WebViewFactory; import dalvik.system.DexFile; @@ -54,7 +51,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.util.ArrayList; /** diff --git a/core/java/com/android/internal/view/ActionModeWrapper.java b/core/java/com/android/internal/view/ActionModeWrapper.java index 72066b9..d98617d 100644 --- a/core/java/com/android/internal/view/ActionModeWrapper.java +++ b/core/java/com/android/internal/view/ActionModeWrapper.java @@ -113,6 +113,10 @@ public class ActionModeWrapper extends ActionMode { } } + public ActionMode getWrappedActionMode() { + return mActionMode; + } + /** * Set the current type as final and create the necessary ActionMode. After this call, any * changes to the ActionMode type will be ignored. @@ -165,6 +169,8 @@ public class ActionModeWrapper extends ActionMode { public void finish() { if (mActionMode != null) { mActionMode.finish(); + } else { + mCallback.onDestroyActionMode(this); } } diff --git a/core/java/com/android/internal/view/menu/ActionMenuItem.java b/core/java/com/android/internal/view/menu/ActionMenuItem.java index ed676bb..00af401 100644 --- a/core/java/com/android/internal/view/menu/ActionMenuItem.java +++ b/core/java/com/android/internal/view/menu/ActionMenuItem.java @@ -18,6 +18,8 @@ package com.android.internal.view.menu; import android.content.Context; import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.view.ActionProvider; import android.view.ContextMenu.ContextMenuInfo; @@ -42,6 +44,7 @@ public class ActionMenuItem implements MenuItem { private Drawable mIconDrawable; private int mIconResId = NO_ICON; + private TintInfo mIconTintInfo; private Context mContext; @@ -158,12 +161,14 @@ public class ActionMenuItem implements MenuItem { public MenuItem setIcon(Drawable icon) { mIconDrawable = icon; mIconResId = NO_ICON; + applyIconTint(); return this; } public MenuItem setIcon(int iconRes) { mIconResId = iconRes; mIconDrawable = mContext.getDrawable(iconRes); + applyIconTint(); return this; } @@ -274,4 +279,48 @@ public class ActionMenuItem implements MenuItem { // No need to save the listener; ActionMenuItem does not support collapsing items. return this; } + + @Override + public MenuItem setIconTintList(ColorStateList tintList) { + if (mIconTintInfo == null) { + mIconTintInfo = new TintInfo(); + } + mIconTintInfo.mTintList = tintList; + mIconTintInfo.mHasTintList = true; + applyIconTint(); + return this; + } + + @Override + public MenuItem setIconTintMode(PorterDuff.Mode tintMode) { + if (mIconTintInfo == null) { + mIconTintInfo = new TintInfo(); + } + mIconTintInfo.mTintMode = tintMode; + mIconTintInfo.mHasTintMode = true; + applyIconTint(); + return this; + } + + private void applyIconTint() { + final TintInfo tintInfo = mIconTintInfo; + if (mIconDrawable != null && tintInfo != null) { + if (tintInfo.mHasTintList || tintInfo.mHasTintMode) { + mIconDrawable = mIconDrawable.mutate(); + if (tintInfo.mHasTintList) { + mIconDrawable.setTintList(tintInfo.mTintList); + } + if (tintInfo.mHasTintMode) { + mIconDrawable.setTintMode(tintInfo.mTintMode); + } + } + } + } + + private static class TintInfo { + ColorStateList mTintList; + PorterDuff.Mode mTintMode; + boolean mHasTintMode; + boolean mHasTintList; + } } diff --git a/core/java/com/android/internal/view/menu/MenuItemImpl.java b/core/java/com/android/internal/view/menu/MenuItemImpl.java index 3b1f20d..ef4e546 100644 --- a/core/java/com/android/internal/view/menu/MenuItemImpl.java +++ b/core/java/com/android/internal/view/menu/MenuItemImpl.java @@ -21,6 +21,8 @@ import com.android.internal.view.menu.MenuView.ItemView; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.ActionProvider; @@ -60,6 +62,11 @@ public final class MenuItemImpl implements MenuItem { * needed). */ private int mIconResId = NO_ICON; + + /** + * Tint info for the icon + */ + private TintInfo mIconTintInfo; /** The menu to which this item belongs */ private MenuBuilder mMenu; @@ -385,10 +392,10 @@ public final class MenuItemImpl implements MenuItem { } if (mIconResId != NO_ICON) { - Drawable icon = mMenu.getContext().getDrawable(mIconResId); + mIconDrawable = mMenu.getContext().getDrawable(mIconResId); mIconResId = NO_ICON; - mIconDrawable = icon; - return icon; + applyIconTint(); + return mIconDrawable; } return null; @@ -397,6 +404,7 @@ public final class MenuItemImpl implements MenuItem { public MenuItem setIcon(Drawable icon) { mIconResId = NO_ICON; mIconDrawable = icon; + applyIconTint(); mMenu.onItemsChanged(false); return this; @@ -670,4 +678,48 @@ public final class MenuItemImpl implements MenuItem { public boolean isActionViewExpanded() { return mIsActionViewExpanded; } + + @Override + public MenuItem setIconTintList(ColorStateList tintList) { + if (mIconTintInfo == null) { + mIconTintInfo = new TintInfo(); + } + mIconTintInfo.mTintList = tintList; + mIconTintInfo.mHasTintList = true; + applyIconTint(); + return this; + } + + @Override + public MenuItem setIconTintMode(PorterDuff.Mode tintMode) { + if (mIconTintInfo == null) { + mIconTintInfo = new TintInfo(); + } + mIconTintInfo.mTintMode = tintMode; + mIconTintInfo.mHasTintMode = true; + applyIconTint(); + return this; + } + + private void applyIconTint() { + final TintInfo tintInfo = mIconTintInfo; + if (mIconDrawable != null && tintInfo != null) { + if (tintInfo.mHasTintList || tintInfo.mHasTintMode) { + mIconDrawable = mIconDrawable.mutate(); + if (tintInfo.mHasTintList) { + mIconDrawable.setTintList(tintInfo.mTintList); + } + if (tintInfo.mHasTintMode) { + mIconDrawable.setTintMode(tintInfo.mTintMode); + } + } + } + } + + private static class TintInfo { + ColorStateList mTintList; + PorterDuff.Mode mTintMode; + boolean mHasTintMode; + boolean mHasTintList; + } } diff --git a/core/java/com/android/internal/widget/ActionBarContainer.java b/core/java/com/android/internal/widget/ActionBarContainer.java index 7937a95..eaf0bbc 100644 --- a/core/java/com/android/internal/widget/ActionBarContainer.java +++ b/core/java/com/android/internal/widget/ActionBarContainer.java @@ -23,7 +23,6 @@ import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Outline; import android.graphics.PixelFormat; -import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.ActionMode; @@ -32,8 +31,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; -import java.util.List; - /** * This class acts as a container for the action bar view and action mode context views. * It applies special styles as needed to help handle animated transitions between them. @@ -387,7 +384,7 @@ public class ActionBarContainer extends FrameLayout { } @Override - public void setColorFilter(ColorFilter cf) { + public void setColorFilter(ColorFilter colorFilter) { } @Override diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java index ae5999a..42d875d 100644 --- a/core/java/com/android/internal/widget/ActionBarContextView.java +++ b/core/java/com/android/internal/widget/ActionBarContextView.java @@ -17,8 +17,6 @@ package com.android.internal.widget; import com.android.internal.R; -import android.util.TypedValue; -import android.view.ContextThemeWrapper; import android.widget.ActionMenuPresenter; import android.widget.ActionMenuView; import com.android.internal.view.menu.MenuBuilder; diff --git a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java index cca48d3..c3a7460 100644 --- a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java +++ b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java @@ -32,7 +32,6 @@ import android.util.IntProperty; import android.util.Log; import android.util.Property; import android.util.SparseArray; -import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.view.ViewGroup; diff --git a/core/java/com/android/internal/widget/ScrollingTabContainerView.java b/core/java/com/android/internal/widget/ScrollingTabContainerView.java index 825fcad..ffd9b24 100644 --- a/core/java/com/android/internal/widget/ScrollingTabContainerView.java +++ b/core/java/com/android/internal/widget/ScrollingTabContainerView.java @@ -31,7 +31,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.DecelerateInterpolator; import android.widget.AdapterView; import android.widget.BaseAdapter; diff --git a/core/java/com/android/internal/widget/SubtitleView.java b/core/java/com/android/internal/widget/SubtitleView.java index a206e7f..8c395ec 100644 --- a/core/java/com/android/internal/widget/SubtitleView.java +++ b/core/java/com/android/internal/widget/SubtitleView.java @@ -31,7 +31,6 @@ import android.text.Layout.Alignment; import android.text.StaticLayout; import android.text.TextPaint; import android.util.AttributeSet; -import android.util.DisplayMetrics; import android.view.View; import android.view.accessibility.CaptioningManager.CaptionStyle; diff --git a/core/java/com/android/internal/widget/SwipeDismissLayout.java b/core/java/com/android/internal/widget/SwipeDismissLayout.java index d617c05..89990c2 100644 --- a/core/java/com/android/internal/widget/SwipeDismissLayout.java +++ b/core/java/com/android/internal/widget/SwipeDismissLayout.java @@ -19,6 +19,7 @@ package com.android.internal.widget; import android.animation.TimeInterpolator; import android.app.Activity; import android.content.Context; +import android.content.res.TypedArray; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; @@ -38,6 +39,7 @@ public class SwipeDismissLayout extends FrameLayout { private static final String TAG = "SwipeDismissLayout"; private static final float DISMISS_MIN_DRAG_WIDTH_RATIO = .33f; + private boolean mUseDynamicTranslucency = true; public interface OnDismissedListener { void onDismissed(SwipeDismissLayout layout); @@ -85,7 +87,7 @@ public class SwipeDismissLayout extends FrameLayout { // and temporarily disables translucency when it is fully visible. // As soon as the user starts swiping, we will re-enable // translucency. - if (getContext() instanceof Activity) { + if (mUseDynamicTranslucency && getContext() instanceof Activity) { ((Activity) getContext()).convertFromTranslucent(); } } @@ -117,6 +119,11 @@ public class SwipeDismissLayout extends FrameLayout { android.R.integer.config_shortAnimTime); mCancelInterpolator = new DecelerateInterpolator(1.5f); mDismissInterpolator = new AccelerateInterpolator(1.5f); + TypedArray a = context.getTheme().obtainStyledAttributes( + com.android.internal.R.styleable.Theme); + mUseDynamicTranslucency = !a.hasValue( + com.android.internal.R.styleable.Window_windowIsTranslucent); + a.recycle(); } public void setOnDismissedListener(OnDismissedListener listener) { @@ -230,7 +237,7 @@ public class SwipeDismissLayout extends FrameLayout { mLastX = ev.getRawX(); updateSwiping(ev); if (mSwiping) { - if (getContext() instanceof Activity) { + if (mUseDynamicTranslucency && getContext() instanceof Activity) { ((Activity) getContext()).convertToTranslucent(null, null); } setProgress(ev.getRawX() - mDownX); @@ -254,7 +261,7 @@ public class SwipeDismissLayout extends FrameLayout { } protected void cancel() { - if (getContext() instanceof Activity) { + if (mUseDynamicTranslucency && getContext() instanceof Activity) { ((Activity) getContext()).convertFromTranslucent(); } if (mProgressListener != null) { diff --git a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java index 8d1f73a..54df87b 100644 --- a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java +++ b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java @@ -27,8 +27,6 @@ import android.os.Parcelable; import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; -import android.util.TypedValue; -import android.view.ContextThemeWrapper; import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; diff --git a/core/java/com/android/server/net/NetlinkTracker.java b/core/java/com/android/server/net/NetlinkTracker.java index 0dde465..d45982e 100644 --- a/core/java/com/android/server/net/NetlinkTracker.java +++ b/core/java/com/android/server/net/NetlinkTracker.java @@ -24,11 +24,9 @@ import android.util.Log; import java.net.InetAddress; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Objects; import java.util.Set; /** |