Merge "Keep LMP from breaking KitKat API" into lmp-dev
diff --git a/api/current.txt b/api/current.txt
index e48e5d59..f479430 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -260,6 +260,7 @@
public static final class R.attr {
ctor public R.attr();
+ field public static final int __removed2 = 16843937; // 0x10104a1
field public static final int absListViewStyle = 16842858; // 0x101006a
field public static final int accessibilityEventTypes = 16843648; // 0x1010380
field public static final int accessibilityFeedbackType = 16843650; // 0x1010382
@@ -482,7 +483,7 @@
field public static final int datePickerMode = 16843956; // 0x10104b4
field public static final int datePickerStyle = 16843612; // 0x101035c
field public static final int dateTextAppearance = 16843593; // 0x1010349
- field public static final int dayOfWeekBackgroundColor = 16843924; // 0x1010494
+ field public static final int dayOfWeekBackground = 16843924; // 0x1010494
field public static final int dayOfWeekTextAppearance = 16843925; // 0x1010495
field public static final int debuggable = 16842767; // 0x101000f
field public static final int defaultValue = 16843245; // 0x10101ed
@@ -663,7 +664,6 @@
field public static final int hasCode = 16842764; // 0x101000c
field public static final int headerAmPmTextAppearance = 16843936; // 0x10104a0
field public static final int headerBackground = 16843055; // 0x101012f
- field public static final int headerBackgroundColor = 16843937; // 0x10104a1
field public static final int headerDayOfMonthTextAppearance = 16843927; // 0x1010497
field public static final int headerDividersEnabled = 16843310; // 0x101022e
field public static final int headerMonthTextAppearance = 16843926; // 0x1010496
diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java
index a64e0ed..2c596e5 100644
--- a/core/java/android/app/AlarmManager.java
+++ b/core/java/android/app/AlarmManager.java
@@ -17,6 +17,7 @@
package android.app;
import android.annotation.SdkConstant;
+import android.annotation.SystemApi;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
@@ -385,6 +386,7 @@
}
/** @hide */
+ @SystemApi
public void set(int type, long triggerAtMillis, long windowMillis, long intervalMillis,
PendingIntent operation, WorkSource workSource) {
setImpl(type, triggerAtMillis, windowMillis, intervalMillis, operation, workSource, null);
diff --git a/core/java/android/net/NetworkRequest.java b/core/java/android/net/NetworkRequest.java
index 83bdfaa..5a09b46 100644
--- a/core/java/android/net/NetworkRequest.java
+++ b/core/java/android/net/NetworkRequest.java
@@ -52,6 +52,9 @@
* @hide
*/
public NetworkRequest(NetworkCapabilities nc, int legacyType, int rId) {
+ if (nc == null) {
+ throw new NullPointerException();
+ }
requestId = rId;
networkCapabilities = nc;
this.legacyType = legacyType;
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 21e7c6b..92ad4e8 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -444,16 +444,19 @@
* <a name="Drawing"></a>
* <h3>Drawing</h3>
* <p>
- * Drawing is handled by walking the tree and rendering each view that
- * intersects the invalid region. Because the tree is traversed in-order,
- * this means that parents will draw before (i.e., behind) their children, with
- * siblings drawn in the order they appear in the tree.
- * If you set a background drawable for a View, then the View will draw it for you
- * before calling back to its <code>onDraw()</code> method.
+ * Drawing is handled by walking the tree and recording the drawing commands of
+ * any View that needs to update. After this, the drawing commands of the
+ * entire tree are issued to screen, clipped to the newly damaged area.
* </p>
*
* <p>
- * Note that the framework will not draw views that are not in the invalid region.
+ * The tree is largely recorded and drawn in order, with parents drawn before
+ * (i.e., behind) their children, with siblings drawn in the order they appear
+ * in the tree. If you set a background drawable for a View, then the View will
+ * draw it before calling back to its <code>onDraw()</code> method. The child
+ * drawing order can be overridden with
+ * {@link ViewGroup#setChildrenDrawingOrderEnabled(boolean) custom child drawing order}
+ * in a ViewGroup, and with {@link #setZ(float)} custom Z values} set on Views.
* </p>
*
* <p>
@@ -10825,6 +10828,12 @@
/**
* Sets whether the View's Outline should be used to clip the contents of the View.
* <p>
+ * Only a single non-rectangular clip can be applied on a View at any time.
+ * Circular clips from a {@link ViewAnimationUtils#createCircularReveal(View, int, int, float, float)
+ * circular reveal} animation take priority over Outline clipping, and
+ * child Outline clipping takes priority over Outline clipping done by a
+ * parent.
+ * <p>
* Note that this flag will only be respected if the View's Outline returns true from
* {@link Outline#canClip()}.
*
@@ -15091,10 +15100,12 @@
bounds.set(0, 0, mRight - mLeft, mBottom - mTop);
}
+ canvas.save();
canvas.translate(mScrollX, mScrollY);
+ canvas.clipRect(bounds, Region.Op.REPLACE);
drawable.setBounds(bounds);
drawable.draw(canvas);
- canvas.translate(-mScrollX, -mScrollY);
+ canvas.restore();
}
/**
diff --git a/core/java/android/view/ViewAnimationUtils.java b/core/java/android/view/ViewAnimationUtils.java
index 7ced088..001cd01 100644
--- a/core/java/android/view/ViewAnimationUtils.java
+++ b/core/java/android/view/ViewAnimationUtils.java
@@ -27,9 +27,13 @@
private ViewAnimationUtils() {}
/**
* Returns an Animator which can animate a clipping circle.
- *
+ * <p>
* Any shadow cast by the View will respect the circular clip from this animator.
- *
+ * <p>
+ * Only a single non-rectangular clip can be applied on a View at any time.
+ * Views clipped by a circular reveal animation take priority over
+ * {@link View#setClipToOutline(boolean) View Outline clipping}.
+ * <p>
* Note that the animation returned here is a one-shot animation. It cannot
* be re-used, and once started it cannot be paused or resumed.
*
@@ -39,7 +43,7 @@
* @param startRadius The starting radius of the animating circle.
* @param endRadius The ending radius of the animating circle.
*/
- public static final Animator createCircularReveal(View view,
+ public static Animator createCircularReveal(View view,
int centerX, int centerY, float startRadius, float endRadius) {
return new RevealAnimator(view, centerX, centerY, startRadius, endRadius);
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index adad082..974fe4e 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -5034,6 +5034,9 @@
/**
* Tells the ViewGroup whether to draw its children in the order defined by the method
* {@link #getChildDrawingOrder(int, int)}.
+ * <p>
+ * Note that {@link View#getZ() Z} reordering, done by {@link #dispatchDraw(Canvas)},
+ * will override custom child ordering done via this method.
*
* @param enabled true if the order of the children when drawing is determined by
* {@link #getChildDrawingOrder(int, int)}, false otherwise
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 26c1f96..2729bd0 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -71,9 +71,9 @@
* @attr ref android.R.styleable#DatePicker_minDate
* @attr ref android.R.styleable#DatePicker_spinnersShown
* @attr ref android.R.styleable#DatePicker_calendarViewShown
- * @attr ref android.R.styleable#DatePicker_dayOfWeekBackgroundColor
+ * @attr ref android.R.styleable#DatePicker_dayOfWeekBackground
* @attr ref android.R.styleable#DatePicker_dayOfWeekTextAppearance
- * @attr ref android.R.styleable#DatePicker_headerBackgroundColor
+ * @attr ref android.R.styleable#DatePicker_headerBackground
* @attr ref android.R.styleable#DatePicker_headerMonthTextAppearance
* @attr ref android.R.styleable#DatePicker_headerDayOfMonthTextAppearance
* @attr ref android.R.styleable#DatePicker_headerYearTextAppearance
diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java
index 7df1fa3..eed49bf 100644
--- a/core/java/android/widget/DatePickerCalendarDelegate.java
+++ b/core/java/android/widget/DatePickerCalendarDelegate.java
@@ -21,7 +21,7 @@
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.graphics.Color;
+import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.format.DateFormat;
@@ -149,16 +149,12 @@
mDayOfWeekView.setTextAppearance(context, dayOfWeekTextAppearanceResId);
}
- final int dayOfWeekBackgroundColor = a.getColor(
- R.styleable.DatePicker_dayOfWeekBackgroundColor, Color.TRANSPARENT);
- mDayOfWeekView.setBackgroundColor(dayOfWeekBackgroundColor);
+ mDayOfWeekView.setBackground(a.getDrawable(R.styleable.DatePicker_dayOfWeekBackground));
+
+ dateLayout.setBackground(a.getDrawable(R.styleable.DatePicker_headerBackground));
final int headerSelectedTextColor = a.getColor(
R.styleable.DatePicker_headerSelectedTextColor, defaultHighlightColor);
- final int headerBackgroundColor = a.getColor(R.styleable.DatePicker_headerBackgroundColor,
- Color.TRANSPARENT);
- dateLayout.setBackgroundColor(headerBackgroundColor);
-
final int monthTextAppearanceResId = a.getResourceId(
R.styleable.DatePicker_headerMonthTextAppearance, -1);
if (monthTextAppearanceResId != -1) {
diff --git a/core/java/android/widget/RadialTimePickerView.java b/core/java/android/widget/RadialTimePickerView.java
index adca4cc..d2f68d0 100644
--- a/core/java/android/widget/RadialTimePickerView.java
+++ b/core/java/android/widget/RadialTimePickerView.java
@@ -458,6 +458,7 @@
a.recycle();
setOnTouchListener(this);
+ setClickable(true);
// Initial values
final Calendar calendar = Calendar.getInstance(Locale.getDefault());
@@ -612,9 +613,9 @@
mMinutesTexts[i] = String.format("%02d", MINUTES_NUMBERS[i]);
}
- String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
- mAmPmText[AM] = amPmTexts[0];
- mAmPmText[PM] = amPmTexts[1];
+ String[] amPmStrings = TimePickerClockDelegate.getAmPmStrings(mContext);
+ mAmPmText[AM] = amPmStrings[0];
+ mAmPmText[PM] = amPmStrings[1];
}
private void initData() {
diff --git a/core/java/android/widget/TimePickerSpinnerDelegate.java b/core/java/android/widget/TimePickerSpinnerDelegate.java
index 6169d2e..73e05e8 100644
--- a/core/java/android/widget/TimePickerSpinnerDelegate.java
+++ b/core/java/android/widget/TimePickerSpinnerDelegate.java
@@ -21,7 +21,6 @@
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.graphics.Color;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
@@ -40,7 +39,6 @@
import com.android.internal.R;
-import java.text.DateFormatSymbols;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
@@ -71,6 +69,7 @@
private static final int HOURS_IN_HALF_DAY = 12;
+ private View mHeaderView;
private TextView mHourView;
private TextView mMinuteView;
private TextView mAmPmTextView;
@@ -156,11 +155,8 @@
mAmPmTextView.setTextAppearance(context, headerAmPmTextAppearance);
}
- final int headerBackgroundColor = a.getColor(
- R.styleable.TimePicker_headerBackgroundColor, Color.TRANSPARENT);
- if (headerBackgroundColor != Color.TRANSPARENT) {
- mainView.findViewById(R.id.time_header).setBackgroundColor(headerBackgroundColor);
- }
+ mHeaderView = mainView.findViewById(R.id.time_header);
+ mHeaderView.setBackground(a.getDrawable(R.styleable.TimePicker_headerBackground));
a.recycle();
@@ -194,14 +190,11 @@
}
private void setupListeners() {
- KeyboardListener keyboardListener = new KeyboardListener();
- mDelegator.setOnKeyListener(keyboardListener);
+ mHeaderView.setOnKeyListener(mKeyListener);
+ mHeaderView.setOnFocusChangeListener(mFocusListener);
+ mHeaderView.setFocusable(true);
- mHourView.setOnKeyListener(keyboardListener);
- mMinuteView.setOnKeyListener(keyboardListener);
- mAmPmTextView.setOnKeyListener(keyboardListener);
mRadialTimePickerView.setOnValueSelectedListener(this);
- mRadialTimePickerView.setOnKeyListener(keyboardListener);
mHourView.setOnClickListener(new View.OnClickListener() {
@Override
@@ -641,7 +634,7 @@
if (!isTypedTimeFullyLegal()) {
mTypedTimes.clear();
}
- finishKbMode(true);
+ finishKbMode();
}
}
@@ -776,27 +769,7 @@
* @return true if the key was successfully processed, false otherwise.
*/
private boolean processKeyUp(int keyCode) {
- if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_TAB) {
- if(mInKbMode) {
- if (isTypedTimeFullyLegal()) {
- finishKbMode(true);
- }
- return true;
- }
- } else if (keyCode == KeyEvent.KEYCODE_ENTER) {
- if (mInKbMode) {
- if (!isTypedTimeFullyLegal()) {
- return true;
- }
- finishKbMode(false);
- }
- if (mOnTimeChangedListener != null) {
- mOnTimeChangedListener.onTimeChanged(mDelegator,
- mRadialTimePickerView.getCurrentHour(),
- mRadialTimePickerView.getCurrentMinute());
- }
- return true;
- } else if (keyCode == KeyEvent.KEYCODE_DEL) {
+ if (keyCode == KeyEvent.KEYCODE_DEL) {
if (mInKbMode) {
if (!mTypedTimes.isEmpty()) {
int deleted = deleteLastTypedKey();
@@ -925,9 +898,8 @@
/**
* Get out of keyboard mode. If there is nothing in typedTimes, revert to TimePicker's time.
- * @param updateDisplays If true, update the displays with the relevant time.
*/
- private void finishKbMode(boolean updateDisplays) {
+ private void finishKbMode() {
mInKbMode = false;
if (!mTypedTimes.isEmpty()) {
int values[] = getEnteredTime(null);
@@ -938,10 +910,8 @@
}
mTypedTimes.clear();
}
- if (updateDisplays) {
- updateDisplay(false);
- mRadialTimePickerView.setInputEnabled(true);
- }
+ updateDisplay(false);
+ mRadialTimePickerView.setInputEnabled(true);
}
/**
@@ -1261,7 +1231,7 @@
}
}
- private class KeyboardListener implements View.OnKeyListener {
+ private final View.OnKeyListener mKeyListener = new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_UP) {
@@ -1269,5 +1239,20 @@
}
return false;
}
- }
+ };
+
+ private final View.OnFocusChangeListener mFocusListener = new View.OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (!hasFocus && mInKbMode && isTypedTimeFullyLegal()) {
+ finishKbMode();
+
+ if (mOnTimeChangedListener != null) {
+ mOnTimeChangedListener.onTimeChanged(mDelegator,
+ mRadialTimePickerView.getCurrentHour(),
+ mRadialTimePickerView.getCurrentMinute());
+ }
+ }
+ }
+ };
}
diff --git a/core/res/res/drawable/time_picker_header_material.xml b/core/res/res/drawable/time_picker_header_material.xml
new file mode 100644
index 0000000..cdb92b6
--- /dev/null
+++ b/core/res/res/drawable/time_picker_header_material.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?attr/colorControlHighlight">
+ <item>
+ <color android:color="?attr/colorAccent" />
+ </item>
+</ripple>
diff --git a/core/res/res/layout-land/time_picker_holo.xml b/core/res/res/layout-land/time_picker_holo.xml
index f316f1b..ce90a5b 100644
--- a/core/res/res/layout-land/time_picker_holo.xml
+++ b/core/res/res/layout-land/time_picker_holo.xml
@@ -21,7 +21,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
- android:focusable="true"
android:layout_marginLeft="@dimen/timepicker_minimum_margin_sides"
android:layout_marginRight="@dimen/timepicker_minimum_margin_sides"
android:layout_marginTop="@dimen/timepicker_minimum_margin_top_bottom"
@@ -42,7 +41,5 @@
android:id="@+id/radial_picker"
android:layout_width="@dimen/timepicker_radial_picker_dimen"
android:layout_height="match_parent"
- android:layout_gravity="center"
- android:focusable="true"
- android:focusableInTouchMode="true" />
+ android:layout_gravity="center" />
</LinearLayout>
diff --git a/core/res/res/layout/time_picker_holo.xml b/core/res/res/layout/time_picker_holo.xml
index 483eb6d..08d2211 100644
--- a/core/res/res/layout/time_picker_holo.xml
+++ b/core/res/res/layout/time_picker_holo.xml
@@ -18,20 +18,17 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:focusable="true" >
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<include
- layout="@layout/time_header_label"
- android:layout_width="match_parent"
- android:layout_height="@dimen/timepicker_header_height"
- android:layout_gravity="center" />
+ layout="@layout/time_header_label"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/timepicker_header_height"
+ android:layout_gravity="center" />
<android.widget.RadialTimePickerView
- android:id="@+id/radial_picker"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/timepicker_radial_picker_dimen"
- android:layout_gravity="center"
- android:focusable="true"
- android:focusableInTouchMode="true" />
+ android:id="@+id/radial_picker"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/timepicker_radial_picker_dimen"
+ android:layout_gravity="center" />
</LinearLayout>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 4622995..603fcde 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -4346,7 +4346,7 @@
<!-- @hide The layout of the legacy DatePicker. -->
<attr name="legacyLayout" />
<!-- The background color for the date selector 's day of week. -->
- <attr name="dayOfWeekBackgroundColor" format="color" />
+ <attr name="dayOfWeekBackground" format="color|reference" />
<!-- The text color for the date selector's day of week. -->
<attr name="dayOfWeekTextAppearance" format="reference" />
<!-- The month's text appearance in the date selector. -->
@@ -4355,8 +4355,8 @@
<attr name="headerDayOfMonthTextAppearance" format="reference" />
<!-- The year's text appearance in the date selector. -->
<attr name="headerYearTextAppearance" format="reference" />
- <!-- The background color for the date selector. -->
- <attr name="headerBackgroundColor" />
+ <!-- The background for the date selector. -->
+ <attr name="headerBackground" />
<!-- @hide The selected text color for the date selector. Used as a
backup if the text appearance does not explicitly have a color
set for the selected state. -->
@@ -4653,29 +4653,29 @@
<attr name="legacyLayout" format="reference" />
<!-- @hide The layout of the time picker. -->
<attr name="internalLayout" />
- <!-- The text appearance for the AM/PM header of the TimePicker. -->
+ <!-- The text appearance for the AM/PM header. -->
<attr name="headerAmPmTextAppearance" format="reference" />
- <!-- The text appearance for the time header of the TimePicker. -->
+ <!-- The text appearance for the time header. -->
<attr name="headerTimeTextAppearance" format="reference" />
<!-- @hide The text color for selected time header of the TimePicker.
This will override the value from the text appearance if it does
not explicitly have a color set for the selected state. -->
<attr name="headerSelectedTextColor" format="color" />
- <!-- The background color for the header of the TimePicker. -->
- <attr name="headerBackgroundColor" format="color" />
- <!-- The color for the hours/minutes numbers of the TimePicker. -->
+ <!-- The background for the header containing the currently selected time. -->
+ <attr name="headerBackground" />
+ <!-- The color for the hours/minutes numbers. -->
<attr name="numbersTextColor" format="color" />
- <!-- The background color for the hours/minutes numbers of the TimePicker. -->
+ <!-- The background color for the hours/minutes numbers. -->
<attr name="numbersBackgroundColor" format="color" />
- <!-- The color for the AM/PM selectors of the TimePicker. -->
+ <!-- The color for the AM/PM selectors. -->
<attr name="amPmTextColor" format="color" />
- <!-- The background color state list for the AM/PM selectors of the TimePicker. -->
+ <!-- The background color state list for the AM/PM selectors. -->
<attr name="amPmBackgroundColor" format="color" />
<!-- @hide The background color for the AM/PM selectors of the
TimePicker when selected. Used if the background color does not
explicitly have a color set for the selected state. -->
<attr name="amPmSelectedBackgroundColor" format="color" />
- <!-- The color for the hours/minutes selector of the TimePicker. -->
+ <!-- The color for the hours/minutes selector. -->
<attr name="numbersSelectorColor" format="color" />
<!-- Defines the look of the widget. Prior to the L release, the only choice was
spinner. As of L, with the Material theme selected, the default layout is clock,
@@ -7435,6 +7435,9 @@
<!-- @removed -->
<attr name="__removed1" format="reference" />
+ <!-- TODO: Spacer to be removed from here and public.xml -->
+ <attr name="__removed2" format="reference" />
+
<!-- Attributes that can be used with <code>rating-system-definition</code> tags inside of the
XML resource that describes TV content rating of a {@link android.media.tv.TvInputService},
which is referenced from its
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 75c0e2c..4bf4531 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2235,7 +2235,7 @@
<public type="attr" name="launchTaskBehindTargetAnimation" />
<public type="attr" name="launchTaskBehindSourceAnimation" />
<public type="attr" name="restrictionType" />
- <public type="attr" name="dayOfWeekBackgroundColor" />
+ <public type="attr" name="dayOfWeekBackground" />
<public type="attr" name="dayOfWeekTextAppearance" />
<public type="attr" name="headerMonthTextAppearance" />
<public type="attr" name="headerDayOfMonthTextAppearance" />
@@ -2248,7 +2248,7 @@
<public type="attr" name="timePickerDialogTheme" />
<public type="attr" name="headerTimeTextAppearance" />
<public type="attr" name="headerAmPmTextAppearance" />
- <public type="attr" name="headerBackgroundColor" />
+ <public type="attr" name="__removed2" />
<public type="attr" name="numbersTextColor" />
<public type="attr" name="numbersBackgroundColor" />
<public type="attr" name="numbersSelectorColor" />
diff --git a/core/res/res/values/styles_holo.xml b/core/res/res/values/styles_holo.xml
index 2a54ccf..c7d2db1 100644
--- a/core/res/res/values/styles_holo.xml
+++ b/core/res/res/values/styles_holo.xml
@@ -468,7 +468,7 @@
<item name="internalLayout">@layout/time_picker_holo</item>
<item name="headerTimeTextAppearance">@style/TextAppearance.Holo.TimePicker.TimeLabel</item>
<item name="headerAmPmTextAppearance">@style/TextAppearance.Holo.TimePicker.AmPmLabel</item>
- <item name="headerBackgroundColor">@color/timepicker_default_background_holo_dark</item>
+ <item name="headerBackground">@color/timepicker_default_background_holo_dark</item>
<item name="headerSelectedTextColor">@color/holo_blue_light</item>
<item name="numbersTextColor">@color/timepicker_default_text_color_holo_dark</item>
<item name="numbersBackgroundColor">@color/timepicker_default_background_holo_dark</item>
@@ -484,9 +484,9 @@
<item name="internalLayout">@layout/date_picker_holo</item>
<item name="calendarViewShown">true</item>
<!-- New-style date picker attributes. -->
- <item name="dayOfWeekBackgroundColor">@color/datepicker_default_header_dayofweek_background_color_holo_dark</item>
+ <item name="dayOfWeekBackground">@color/datepicker_default_header_dayofweek_background_color_holo_dark</item>
<item name="dayOfWeekTextAppearance">@style/TextAppearance.Holo.DatePicker.DayOfWeekLabel</item>
- <item name="headerBackgroundColor">@color/datepicker_default_header_selector_background_holo_dark</item>
+ <item name="headerBackground">@color/datepicker_default_header_selector_background_holo_dark</item>
<item name="headerMonthTextAppearance">@style/TextAppearance.Holo.DatePicker.Selector.MonthLabel</item>
<item name="headerDayOfMonthTextAppearance">@style/TextAppearance.Holo.DatePicker.Selector.DayOfMonthLabel</item>
<item name="headerYearTextAppearance">@style/TextAppearance.Holo.DatePicker.Selector.YearLabel</item>
@@ -892,7 +892,7 @@
<item name="internalLayout">@layout/time_picker_holo</item>
<item name="headerTimeTextAppearance">@style/TextAppearance.Holo.Light.TimePicker.TimeLabel</item>
<item name="headerAmPmTextAppearance">@style/TextAppearance.Holo.Light.TimePicker.AmPmLabel</item>
- <item name="headerBackgroundColor">@color/timepicker_default_background_holo_light</item>
+ <item name="headerBackground">@color/timepicker_default_background_holo_light</item>
<item name="headerSelectedTextColor">@color/holo_blue_light</item>
<item name="numbersTextColor">@color/timepicker_default_text_color_holo_light</item>
<item name="numbersBackgroundColor">@color/timepicker_default_background_holo_light</item>
@@ -908,12 +908,12 @@
<item name="internalLayout">@layout/date_picker_holo</item>
<item name="calendarViewShown">true</item>
<!-- New-style date picker attributes. -->
- <item name="dayOfWeekBackgroundColor">@color/datepicker_default_header_dayofweek_background_color_holo_light</item>
+ <item name="dayOfWeekBackground">@color/datepicker_default_header_dayofweek_background_color_holo_light</item>
<item name="dayOfWeekTextAppearance">@style/TextAppearance.Holo.Light.DatePicker.DayOfWeekLabel</item>
<item name="headerMonthTextAppearance">@style/TextAppearance.Holo.Light.DatePicker.Selector.MonthLabel</item>
<item name="headerDayOfMonthTextAppearance">@style/TextAppearance.Holo.Light.DatePicker.Selector.DayOfMonthLabel</item>
<item name="headerYearTextAppearance">@style/TextAppearance.Holo.Light.DatePicker.Selector.YearLabel</item>
- <item name="headerBackgroundColor">@color/datepicker_default_header_selector_background_holo_light</item>
+ <item name="headerBackground">@color/datepicker_default_header_selector_background_holo_light</item>
<item name="headerSelectedTextColor">@color/holo_blue_light</item>
<item name="yearListItemTextAppearance">@style/TextAppearance.Holo.Light.DatePicker.List.YearLabel</item>
<item name="yearListSelectorColor">@color/datepicker_default_circle_background_color_holo_light</item>
diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml
index 77484e6..a7335af 100644
--- a/core/res/res/values/styles_material.xml
+++ b/core/res/res/values/styles_material.xml
@@ -619,7 +619,7 @@
<item name="headerTimeTextAppearance">@style/TextAppearance.Material.TimePicker.TimeLabel</item>
<item name="headerAmPmTextAppearance">@style/TextAppearance.Material.TimePicker.AmPmLabel</item>
<item name="headerSelectedTextColor">?attr/textColorPrimaryInverse</item>
- <item name="headerBackgroundColor">?attr/colorAccent</item>
+ <item name="headerBackground">@drawable/time_picker_header_material</item>
<item name="numbersTextColor">?attr/textColorSecondary</item>
<item name="numbersBackgroundColor">#10ffffff</item>
<item name="amPmTextColor">?attr/textColorSecondary</item>
@@ -634,13 +634,13 @@
<!-- Attributes for new-style DatePicker. -->
<item name="internalLayout">@layout/date_picker_holo</item>
<item name="calendarViewShown">true</item>
- <item name="dayOfWeekBackgroundColor">#10000000</item>
+ <item name="dayOfWeekBackground">#10000000</item>
<item name="dayOfWeekTextAppearance">@style/TextAppearance.Material.DatePicker.DayOfWeekLabel</item>
<item name="headerMonthTextAppearance">@style/TextAppearance.Material.DatePicker.MonthLabel</item>
<item name="headerDayOfMonthTextAppearance">@style/TextAppearance.Material.DatePicker.DayOfMonthLabel</item>
<item name="headerYearTextAppearance">@style/TextAppearance.Material.DatePicker.YearLabel</item>
<item name="headerSelectedTextColor">?attr/textColorPrimaryInverse</item>
- <item name="headerBackgroundColor">?attr/colorAccent</item>
+ <item name="headerBackground">?attr/colorAccent</item>
<item name="yearListItemTextAppearance">@style/TextAppearance.Material.DatePicker.List.YearLabel</item>
<item name="yearListSelectorColor">?attr/colorControlActivated</item>
<item name="calendarTextColor">?attr/textColorSecondary</item>
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 6a92a6e..8fb1f64 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -413,7 +413,7 @@
handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
}
- // TODO: support both reveal clip and outline clip simultaneously
+ // TODO: support nesting round rect clips
if (mProperties.getRevealClip().willClip()) {
Rect bounds;
mProperties.getRevealClip().getBounds(&bounds);
@@ -421,7 +421,6 @@
} else if (mProperties.getOutline().willClip()) {
renderer.setClippingOutline(handler.allocator(), &(mProperties.getOutline()));
}
-
}
/**
diff --git a/libs/hwui/Snapshot.cpp b/libs/hwui/Snapshot.cpp
index ecc47d2..cf8229fd 100644
--- a/libs/hwui/Snapshot.cpp
+++ b/libs/hwui/Snapshot.cpp
@@ -216,14 +216,22 @@
// Clipping round rect
///////////////////////////////////////////////////////////////////////////////
-void Snapshot::setClippingRoundRect(LinearAllocator& allocator, const Rect& bounds, float radius) {
+void Snapshot::setClippingRoundRect(LinearAllocator& allocator, const Rect& bounds,
+ float radius, bool highPriority) {
if (bounds.isEmpty()) {
clipRect->setEmpty();
return;
}
+ if (roundRectClipState && roundRectClipState->highPriority) {
+ // ignore, don't replace, already have a high priority clip
+ return;
+ }
+
RoundRectClipState* state = new (allocator) RoundRectClipState;
+ state->highPriority = highPriority;
+
// store the inverse drawing matrix
Matrix4 roundRectDrawingMatrix;
roundRectDrawingMatrix.load(getOrthoMatrix());
diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index ad4ee9d..549de9b 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -55,6 +55,7 @@
|| rect.intersects(dangerRects[3]);
}
+ bool highPriority;
Matrix4 matrix;
Rect dangerRects[4];
Rect innerRect;
@@ -166,8 +167,11 @@
/**
* Sets (and replaces) the current clipping outline
+ *
+ * If the current round rect clip is high priority, the incoming clip is ignored.
*/
- void setClippingRoundRect(LinearAllocator& allocator, const Rect& bounds, float radius);
+ void setClippingRoundRect(LinearAllocator& allocator, const Rect& bounds,
+ float radius, bool highPriority);
/**
* Indicates whether this snapshot should be ignored. A snapshot
diff --git a/libs/hwui/StatefulBaseRenderer.cpp b/libs/hwui/StatefulBaseRenderer.cpp
index 3e1aed3..12b8c8d 100644
--- a/libs/hwui/StatefulBaseRenderer.cpp
+++ b/libs/hwui/StatefulBaseRenderer.cpp
@@ -198,13 +198,13 @@
clipRect(bounds.left, bounds.top, bounds.right, bounds.bottom, SkRegion::kIntersect_Op);
}
if (outlineIsRounded) {
- setClippingRoundRect(allocator, bounds, radius);
+ setClippingRoundRect(allocator, bounds, radius, false);
}
}
void StatefulBaseRenderer::setClippingRoundRect(LinearAllocator& allocator,
- const Rect& rect, float radius) {
- mSnapshot->setClippingRoundRect(allocator, rect, radius);
+ const Rect& rect, float radius, bool highPriority) {
+ mSnapshot->setClippingRoundRect(allocator, rect, radius, highPriority);
}
diff --git a/libs/hwui/StatefulBaseRenderer.h b/libs/hwui/StatefulBaseRenderer.h
index c6974b4..745e48a 100644
--- a/libs/hwui/StatefulBaseRenderer.h
+++ b/libs/hwui/StatefulBaseRenderer.h
@@ -97,7 +97,7 @@
*/
void setClippingOutline(LinearAllocator& allocator, const Outline* outline);
void setClippingRoundRect(LinearAllocator& allocator,
- const Rect& rect, float radius);
+ const Rect& rect, float radius, bool highPriority = true);
inline const mat4* currentTransform() const {
return mSnapshot->transform;
diff --git a/location/java/android/location/Location.java b/location/java/android/location/Location.java
index bdd1195..fcf222b 100644
--- a/location/java/android/location/Location.java
+++ b/location/java/android/location/Location.java
@@ -16,6 +16,7 @@
package android.location;
+import android.annotation.SystemApi;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -771,6 +772,7 @@
* @see #makeComplete
* @hide
*/
+ @SystemApi
public boolean isComplete() {
if (mProvider == null) return false;
if (!mHasAccuracy) return false;
@@ -788,6 +790,7 @@
* @see #isComplete
* @hide
*/
+ @SystemApi
public void makeComplete() {
if (mProvider == null) mProvider = "?";
if (!mHasAccuracy) {
@@ -957,6 +960,7 @@
* @param isFromMockProvider true if this Location came from a mock provider, false otherwise
* @hide
*/
+ @SystemApi
public void setIsFromMockProvider(boolean isFromMockProvider) {
mIsFromMockProvider = isFromMockProvider;
}
diff --git a/location/java/android/location/LocationRequest.java b/location/java/android/location/LocationRequest.java
index c9162fe..271f2bb 100644
--- a/location/java/android/location/LocationRequest.java
+++ b/location/java/android/location/LocationRequest.java
@@ -16,6 +16,7 @@
package android.location;
+import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
@@ -84,6 +85,7 @@
*
* @hide
*/
+@SystemApi
public final class LocationRequest implements Parcelable {
/**
* Used with {@link #setQuality} to request the most accurate locations available.
@@ -166,6 +168,7 @@
}
/** @hide */
+ @SystemApi
public static LocationRequest createFromDeprecatedProvider(String provider, long minTime,
float minDistance, boolean singleShot) {
if (minTime < 0) minTime = 0;
@@ -191,6 +194,7 @@
}
/** @hide */
+ @SystemApi
public static LocationRequest createFromDeprecatedCriteria(Criteria criteria, long minTime,
float minDistance, boolean singleShot) {
if (minTime < 0) minTime = 0;
@@ -475,6 +479,7 @@
/** @hide */
+ @SystemApi
public LocationRequest setProvider(String provider) {
checkProvider(provider);
mProvider = provider;
@@ -482,11 +487,13 @@
}
/** @hide */
+ @SystemApi
public String getProvider() {
return mProvider;
}
/** @hide */
+ @SystemApi
public LocationRequest setSmallestDisplacement(float meters) {
checkDisplacement(meters);
mSmallestDisplacement = meters;
@@ -494,6 +501,7 @@
}
/** @hide */
+ @SystemApi
public float getSmallestDisplacement() {
return mSmallestDisplacement;
}
@@ -508,11 +516,13 @@
* @param workSource WorkSource defining power blame for this location request.
* @hide
*/
+ @SystemApi
public void setWorkSource(WorkSource workSource) {
mWorkSource = workSource;
}
/** @hide */
+ @SystemApi
public WorkSource getWorkSource() {
return mWorkSource;
}
@@ -531,11 +541,13 @@
* @see android.app.AppOpsManager
* @hide
*/
+ @SystemApi
public void setHideFromAppOps(boolean hideFromAppOps) {
mHideFromAppOps = hideFromAppOps;
}
/** @hide */
+ @SystemApi
public boolean getHideFromAppOps() {
return mHideFromAppOps;
}
diff --git a/media/java/android/media/AudioPortEventHandler.java b/media/java/android/media/AudioPortEventHandler.java
index 8d2c172..9db4994 100644
--- a/media/java/android/media/AudioPortEventHandler.java
+++ b/media/java/android/media/AudioPortEventHandler.java
@@ -47,10 +47,7 @@
mListeners = new ArrayList<AudioManager.OnAudioPortUpdateListener>();
// find the looper for our new event handler
- Looper looper = Looper.myLooper();
- if (looper == null) {
- looper = Looper.getMainLooper();
- }
+ Looper looper = Looper.getMainLooper();
if (looper != null) {
mHandler = new Handler(looper) {
diff --git a/media/java/android/media/RemoteController.java b/media/java/android/media/RemoteController.java
index f378cef..fbfac89 100644
--- a/media/java/android/media/RemoteController.java
+++ b/media/java/android/media/RemoteController.java
@@ -789,8 +789,12 @@
void startListeningToSessions() {
final ComponentName listenerComponent = new ComponentName(mContext,
mOnClientUpdateListener.getClass());
+ Handler handler = null;
+ if (Looper.myLooper() == null) {
+ handler = new Handler(Looper.getMainLooper());
+ }
mSessionManager.addOnActiveSessionsChangedListener(mSessionListener, listenerComponent,
- UserHandle.myUserId(), null);
+ UserHandle.myUserId(), handler);
mSessionListener.onActiveSessionsChanged(mSessionManager
.getActiveSessions(listenerComponent));
if (DEBUG) {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 3efd049..e83963d 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -456,7 +456,7 @@
final ActivityRecord r = ActivityRecord.forToken(token);
if (r != null) {
final TaskRecord task = r.task;
- if (task.mActivities.contains(r) && mTaskHistory.contains(task)) {
+ if (task != null && task.mActivities.contains(r) && mTaskHistory.contains(task)) {
if (task.stack != this) Slog.w(TAG,
"Illegal state! task does not point to stack it is in.");
return r;
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 846efc0..f0f249e 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -312,6 +312,12 @@
final PackageHandler mHandler;
+ /**
+ * Messages for {@link #mHandler} that need to wait for system ready before
+ * being dispatched.
+ */
+ private ArrayList<Message> mPostSystemReadyMessages;
+
final int mSdkVersion = Build.VERSION.SDK_INT;
final Context mContext;
@@ -446,9 +452,9 @@
/** Token for keys in mPendingVerification. */
private int mPendingVerificationToken = 0;
- boolean mSystemReady;
- boolean mSafeMode;
- boolean mHasSystemUidErrors;
+ volatile boolean mSystemReady;
+ volatile boolean mSafeMode;
+ volatile boolean mHasSystemUidErrors;
ApplicationInfo mAndroidApplication;
final ActivityInfo mResolveActivity = new ActivityInfo();
@@ -7685,16 +7691,18 @@
}
void schedulePackageCleaning(String packageName, int userId, boolean andCode) {
- if (false) {
- RuntimeException here = new RuntimeException("here");
- here.fillInStackTrace();
- Slog.d(TAG, "Schedule cleaning " + packageName + " user=" + userId
- + " andCode=" + andCode, here);
+ final Message msg = mHandler.obtainMessage(START_CLEANING_PACKAGE,
+ userId, andCode ? 1 : 0, packageName);
+ if (mSystemReady) {
+ msg.sendToTarget();
+ } else {
+ if (mPostSystemReadyMessages == null) {
+ mPostSystemReadyMessages = new ArrayList<>();
+ }
+ mPostSystemReadyMessages.add(msg);
}
- mHandler.sendMessage(mHandler.obtainMessage(START_CLEANING_PACKAGE,
- userId, andCode ? 1 : 0, packageName));
}
-
+
void startCleaningPackages() {
// reader
synchronized (mPackages) {
@@ -12038,6 +12046,14 @@
}
}
sUserManager.systemReady();
+
+ // Kick off any messages waiting for system ready
+ if (mPostSystemReadyMessages != null) {
+ for (Message msg : mPostSystemReadyMessages) {
+ msg.sendToTarget();
+ }
+ mPostSystemReadyMessages = null;
+ }
}
@Override
@@ -13035,6 +13051,9 @@
Iterator<PackageSetting> psit = mSettings.mPackages.values().iterator();
while (psit.hasNext()) {
PackageSetting ps = psit.next();
+ if (ps.pkg == null) {
+ continue;
+ }
final String packageName = ps.pkg.packageName;
// Skip over if system app
if ((ps.pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0) {
diff --git a/telephony/java/android/telephony/SubInfoRecord.java b/telephony/java/android/telephony/SubInfoRecord.java
index 55781fa..3a47269 100644
--- a/telephony/java/android/telephony/SubInfoRecord.java
+++ b/telephony/java/android/telephony/SubInfoRecord.java
@@ -36,6 +36,8 @@
public int mDisplayNumberFormat;
public int mDataRoaming;
public int[] mSimIconRes;
+ public int mMcc;
+ public int mMnc;
public SubInfoRecord() {
this.mSubId = SubscriptionManager.INVALID_SUB_ID;
@@ -48,38 +50,45 @@
this.mDisplayNumberFormat = 0;
this.mDataRoaming = 0;
this.mSimIconRes = new int[2];
+ this.mMcc = 0;
+ this.mMnc = 0;
}
- public SubInfoRecord(long subId, String iccId, int slotId, String displayName,
- int nameSource, int mColor, String mNumber, int displayFormat, int roaming, int[] iconRes) {
+ public SubInfoRecord(long subId, String iccId, int slotId, String displayName, int nameSource,
+ int color, String number, int displayFormat, int roaming, int[] iconRes,
+ int mcc, int mnc) {
this.mSubId = subId;
this.mIccId = iccId;
this.mSlotId = slotId;
this.mDisplayName = displayName;
this.mNameSource = nameSource;
- this.mColor = mColor;
- this.mNumber = mNumber;
+ this.mColor = color;
+ this.mNumber = number;
this.mDisplayNumberFormat = displayFormat;
this.mDataRoaming = roaming;
this.mSimIconRes = iconRes;
+ this.mMcc = mcc;
+ this.mMnc = mnc;
}
public static final Parcelable.Creator<SubInfoRecord> CREATOR = new Parcelable.Creator<SubInfoRecord>() {
public SubInfoRecord createFromParcel(Parcel source) {
- long mSubId = source.readLong();
- String mIccId = source.readString();
- int mSlotId = source.readInt();
- String mDisplayName = source.readString();
- int mNameSource = source.readInt();
- int mColor = source.readInt();
- String mNumber = source.readString();
- int mDisplayNumberFormat = source.readInt();
- int mDataRoaming = source.readInt();
+ long subId = source.readLong();
+ String iccId = source.readString();
+ int slotId = source.readInt();
+ String displayName = source.readString();
+ int nameSource = source.readInt();
+ int color = source.readInt();
+ String number = source.readString();
+ int displayNumberFormat = source.readInt();
+ int dataRoaming = source.readInt();
int[] iconRes = new int[2];
source.readIntArray(iconRes);
+ int mcc = source.readInt();
+ int mnc = source.readInt();
- return new SubInfoRecord(mSubId, mIccId, mSlotId, mDisplayName, mNameSource, mColor, mNumber,
- mDisplayNumberFormat, mDataRoaming, iconRes);
+ return new SubInfoRecord(subId, iccId, slotId, displayName, nameSource, color, number,
+ displayNumberFormat, dataRoaming, iconRes, mcc, mnc);
}
public SubInfoRecord[] newArray(int size) {
@@ -98,6 +107,8 @@
dest.writeInt(mDisplayNumberFormat);
dest.writeInt(mDataRoaming);
dest.writeIntArray(mSimIconRes);
+ dest.writeInt(mMcc);
+ dest.writeInt(mMnc);
}
public int describeContents() {
@@ -109,6 +120,6 @@
+ " mDisplayName=" + mDisplayName + " mNameSource=" + mNameSource
+ " mColor=" + mColor + " mNumber=" + mNumber
+ " mDisplayNumberFormat=" + mDisplayNumberFormat + " mDataRoaming=" + mDataRoaming
- + " mSimIconRes=" + mSimIconRes + "}";
+ + " mSimIconRes=" + mSimIconRes + " mMcc " + mMcc + " mMnc " + mMnc + "}";
}
}
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 2bb2404..b5f8847 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -27,6 +27,7 @@
import com.android.internal.telephony.ISub;
import com.android.internal.telephony.PhoneConstants;
+
import java.util.List;
/**
@@ -204,6 +205,19 @@
/** @hide */
public static final int DATA_ROAMING_DEFAULT = DATA_ROAMING_DISABLE;
+ /**
+ * The MCC associated with a SIM.
+ * <P>Type: INTEGER (int)</P>
+ */
+ public static final String MCC = "mcc";
+
+ /**
+ * The MNC associated with a SIM.
+ * <P>Type: INTEGER (int)</P>
+ */
+ public static final String MNC = "mnc";
+
+
private static final int RES_TYPE_BACKGROUND_DARK = 0;
private static final int RES_TYPE_BACKGROUND_LIGHT = 1;
diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py
index 6bb28e1..393d2ec 100644
--- a/tools/apilint/apilint.py
+++ b/tools/apilint/apilint.py
@@ -20,15 +20,20 @@
Usage: apilint.py current.txt
Usage: apilint.py current.txt previous.txt
+
+You can also splice in blame details like this:
+$ git blame api/current.txt -t -e > /tmp/currentblame.txt
+$ apilint.py /tmp/currentblame.txt previous.txt --no-color
"""
-import re, sys, collections
+import re, sys, collections, traceback
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
def format(fg=None, bg=None, bright=False, bold=False, dim=False, reset=False):
# manually derived from http://en.wikipedia.org/wiki/ANSI_escape_code#Codes
+ if "--no-color" in sys.argv: return ""
codes = []
if reset: codes.append("0")
else:
@@ -43,9 +48,10 @@
class Field():
- def __init__(self, clazz, raw):
+ def __init__(self, clazz, raw, blame):
self.clazz = clazz
self.raw = raw.strip(" {;")
+ self.blame = blame
raw = raw.split()
self.split = list(raw)
@@ -60,14 +66,20 @@
else:
self.value = None
+ self.ident = self.raw.replace(" deprecated ", " ")
+
def __repr__(self):
return self.raw
class Method():
- def __init__(self, clazz, raw):
+ def __init__(self, clazz, raw, blame):
self.clazz = clazz
self.raw = raw.strip(" {;")
+ self.blame = blame
+
+ # drop generics for now
+ raw = re.sub("<.+?>", "", raw)
raw = re.split("[\s(),;]+", raw)
for r in ["", ";"]:
@@ -84,14 +96,24 @@
if r == "throws": break
self.args.append(r)
+ # identity for compat purposes
+ ident = self.raw
+ ident = ident.replace(" deprecated ", " ")
+ ident = ident.replace(" synchronized ", " ")
+ ident = re.sub("<.+?>", "", ident)
+ if " throws " in ident:
+ ident = ident[:ident.index(" throws ")]
+ self.ident = ident
+
def __repr__(self):
return self.raw
class Class():
- def __init__(self, pkg, raw):
+ def __init__(self, pkg, raw, blame):
self.pkg = pkg
self.raw = raw.strip(" {;")
+ self.blame = blame
self.ctors = []
self.fields = []
self.methods = []
@@ -102,19 +124,25 @@
self.fullname = raw[raw.index("class")+1]
elif "interface" in raw:
self.fullname = raw[raw.index("interface")+1]
-
- if "." in self.fullname:
- self.name = self.fullname[self.fullname.rindex(".")+1:]
else:
- self.name = self.fullname
+ raise ValueError("Funky class type %s" % (self.raw))
+
+ if "extends" in raw:
+ self.extends = raw[raw.index("extends")+1]
+ else:
+ self.extends = None
+
+ self.fullname = self.pkg.name + "." + self.fullname
+ self.name = self.fullname[self.fullname.rindex(".")+1:]
def __repr__(self):
return self.raw
class Package():
- def __init__(self, raw):
+ def __init__(self, raw, blame):
self.raw = raw.strip(" {;")
+ self.blame = blame
raw = raw.split()
self.name = raw[raw.index("package")+1]
@@ -124,55 +152,68 @@
def parse_api(fn):
- api = []
+ api = {}
pkg = None
clazz = None
+ blame = None
+
+ re_blame = re.compile("^([a-z0-9]{7,}) \(<([^>]+)>.+?\) (.+?)$")
with open(fn) as f:
for raw in f.readlines():
raw = raw.rstrip()
+ match = re_blame.match(raw)
+ if match is not None:
+ blame = match.groups()[0:2]
+ raw = match.groups()[2]
+ else:
+ blame = None
if raw.startswith("package"):
- pkg = Package(raw)
+ pkg = Package(raw, blame)
elif raw.startswith(" ") and raw.endswith("{"):
- clazz = Class(pkg, raw)
- api.append(clazz)
+ clazz = Class(pkg, raw, blame)
+ api[clazz.fullname] = clazz
elif raw.startswith(" ctor"):
- clazz.ctors.append(Method(clazz, raw))
+ clazz.ctors.append(Method(clazz, raw, blame))
elif raw.startswith(" method"):
- clazz.methods.append(Method(clazz, raw))
+ clazz.methods.append(Method(clazz, raw, blame))
elif raw.startswith(" field"):
- clazz.fields.append(Field(clazz, raw))
+ clazz.fields.append(Field(clazz, raw, blame))
return api
-failures = []
-
-def filter_dupe(s):
- return s.replace(" deprecated ", " ")
+failures = {}
def _fail(clazz, detail, msg):
"""Records an API failure to be processed later."""
global failures
+ sig = "%s-%s-%s" % (clazz.fullname, repr(detail), msg)
+ sig = sig.replace(" deprecated ", " ")
+
res = msg
+ blame = clazz.blame
if detail is not None:
res += "\n in " + repr(detail)
+ blame = detail.blame
res += "\n in " + repr(clazz)
res += "\n in " + repr(clazz.pkg)
- failures.append(filter_dupe(res))
+ if blame is not None:
+ res += "\n last modified by %s in %s" % (blame[1], blame[0])
+ failures[sig] = res
def warn(clazz, detail, msg):
- _fail(clazz, detail, "%sWarning:%s %s" % (format(fg=YELLOW, bg=BLACK), format(reset=True), msg))
+ _fail(clazz, detail, "%sWarning:%s %s" % (format(fg=YELLOW, bg=BLACK, bold=True), format(reset=True), msg))
def error(clazz, detail, msg):
- _fail(clazz, detail, "%sError:%s %s" % (format(fg=RED, bg=BLACK), format(reset=True), msg))
+ _fail(clazz, detail, "%sError:%s %s" % (format(fg=RED, bg=BLACK, bold=True), format(reset=True), msg))
def verify_constants(clazz):
"""All static final constants must be FOO_NAME style."""
- if re.match("R\.[a-z]+", clazz.fullname): return
+ if re.match("android\.R\.[a-z]+", clazz.fullname): return
for f in clazz.fields:
if "static" in f.split and "final" in f.split:
@@ -188,6 +229,10 @@
def verify_class_names(clazz):
"""Try catching malformed class names like myMtp or MTPUser."""
+ if clazz.fullname.startswith("android.opengl"): return
+ if clazz.fullname.startswith("android.renderscript"): return
+ if re.match("android\.R\.[a-z]+", clazz.fullname): return
+
if re.search("[A-Z]{2,}", clazz.name) is not None:
warn(clazz, None, "Class name style should be Mtp not MTP")
if re.match("[^A-Z]", clazz.name):
@@ -196,32 +241,35 @@
def verify_method_names(clazz):
"""Try catching malformed method names, like Foo() or getMTU()."""
- if clazz.pkg.name == "android.opengl": return
+ if clazz.fullname.startswith("android.opengl"): return
+ if clazz.fullname.startswith("android.renderscript"): return
+ if clazz.fullname == "android.system.OsConstants": return
for m in clazz.methods:
if re.search("[A-Z]{2,}", m.name) is not None:
warn(clazz, m, "Method name style should be getMtu() instead of getMTU()")
if re.match("[^a-z]", m.name):
- error(clazz, None, "Method name must start with lowercase char")
+ error(clazz, m, "Method name must start with lowercase char")
def verify_callbacks(clazz):
"""Verify Callback classes.
All callback classes must be abstract.
All methods must follow onFoo() naming style."""
+ if clazz.fullname == "android.speech.tts.SynthesisCallback": return
if clazz.name.endswith("Callbacks"):
- error(clazz, None, "Class must be named exactly Callback")
+ error(clazz, None, "Class name must not be plural")
if clazz.name.endswith("Observer"):
- warn(clazz, None, "Class should be named Callback")
+ warn(clazz, None, "Class should be named FooCallback")
if clazz.name.endswith("Callback"):
if "interface" in clazz.split:
- error(clazz, None, "Callback must be abstract class")
+ error(clazz, None, "Callback must be abstract class to enable extension in future API levels")
for m in clazz.methods:
if not re.match("on[A-Z][a-z]*", m.name):
- error(clazz, m, "Callback method names must be onFoo style")
+ error(clazz, m, "Callback method names must be onFoo() style")
def verify_listeners(clazz):
@@ -233,16 +281,16 @@
if clazz.name.endswith("Listener"):
if " abstract class " in clazz.raw:
- error(clazz, None, "Listener should be interface")
+ error(clazz, None, "Listener should be an interface, otherwise renamed Callback")
for m in clazz.methods:
if not re.match("on[A-Z][a-z]*", m.name):
- error(clazz, m, "Listener method names must be onFoo style")
+ error(clazz, m, "Listener method names must be onFoo() style")
if len(clazz.methods) == 1 and clazz.name.startswith("On"):
m = clazz.methods[0]
if (m.name + "Listener").lower() != clazz.name.lower():
- error(clazz, m, "Single method name should match class name")
+ error(clazz, m, "Single listener method name should match class name")
def verify_actions(clazz):
@@ -255,21 +303,24 @@
for f in clazz.fields:
if f.value is None: continue
if f.name.startswith("EXTRA_"): continue
+ if f.name == "SERVICE_INTERFACE" or f.name == "PROVIDER_INTERFACE": continue
if "static" in f.split and "final" in f.split and f.typ == "java.lang.String":
if "_ACTION" in f.name or "ACTION_" in f.name or ".action." in f.value.lower():
if not f.name.startswith("ACTION_"):
- error(clazz, f, "Intent action must be ACTION_FOO")
+ error(clazz, f, "Intent action constant name must be ACTION_FOO")
else:
- if clazz.name == "Intent":
+ if clazz.fullname == "android.content.Intent":
prefix = "android.intent.action"
- elif clazz.name == "Settings":
+ elif clazz.fullname == "android.provider.Settings":
prefix = "android.settings"
+ elif clazz.fullname == "android.app.admin.DevicePolicyManager" or clazz.fullname == "android.app.admin.DeviceAdminReceiver":
+ prefix = "android.app.action"
else:
prefix = clazz.pkg.name + ".action"
expected = prefix + "." + f.name[7:]
if f.value != expected:
- error(clazz, f, "Inconsistent action value")
+ error(clazz, f, "Inconsistent action value; expected %s" % (expected))
def verify_extras(clazz):
@@ -279,6 +330,9 @@
package android.foo {
String EXTRA_BAR = "android.foo.extra.BAR";
}"""
+ if clazz.fullname == "android.app.Notification": return
+ if clazz.fullname == "android.appwidget.AppWidgetManager": return
+
for f in clazz.fields:
if f.value is None: continue
if f.name.startswith("ACTION_"): continue
@@ -288,13 +342,15 @@
if not f.name.startswith("EXTRA_"):
error(clazz, f, "Intent extra must be EXTRA_FOO")
else:
- if clazz.name == "Intent":
+ if clazz.pkg.name == "android.content" and clazz.name == "Intent":
prefix = "android.intent.extra"
+ elif clazz.pkg.name == "android.app.admin":
+ prefix = "android.app.extra"
else:
prefix = clazz.pkg.name + ".extra"
expected = prefix + "." + f.name[6:]
if f.value != expected:
- error(clazz, f, "Inconsistent extra value")
+ error(clazz, f, "Inconsistent extra value; expected %s" % (expected))
def verify_equals(clazz):
@@ -303,7 +359,7 @@
eq = "equals" in methods
hc = "hashCode" in methods
if eq != hc:
- error(clazz, None, "Must override both equals and hashCode")
+ error(clazz, None, "Must override both equals and hashCode; missing one")
def verify_parcelable(clazz):
@@ -314,34 +370,59 @@
describe = [ i for i in clazz.methods if i.name == "describeContents" ]
if len(creator) == 0 or len(write) == 0 or len(describe) == 0:
- error(clazz, None, "Parcelable requires CREATOR, writeToParcel, and describeContents")
+ error(clazz, None, "Parcelable requires CREATOR, writeToParcel, and describeContents; missing one")
def verify_protected(clazz):
"""Verify that no protected methods are allowed."""
for m in clazz.methods:
if "protected" in m.split:
- error(clazz, m, "Protected method")
+ error(clazz, m, "No protected methods; must be public")
for f in clazz.fields:
if "protected" in f.split:
- error(clazz, f, "Protected field")
+ error(clazz, f, "No protected fields; must be public")
def verify_fields(clazz):
"""Verify that all exposed fields are final.
Exposed fields must follow myName style.
Catch internal mFoo objects being exposed."""
+
+ IGNORE_BARE_FIELDS = [
+ "android.app.ActivityManager.RecentTaskInfo",
+ "android.app.Notification",
+ "android.content.pm.ActivityInfo",
+ "android.content.pm.ApplicationInfo",
+ "android.content.pm.FeatureGroupInfo",
+ "android.content.pm.InstrumentationInfo",
+ "android.content.pm.PackageInfo",
+ "android.content.pm.PackageItemInfo",
+ "android.os.Message",
+ "android.system.StructPollfd",
+ ]
+
for f in clazz.fields:
if not "final" in f.split:
- error(clazz, f, "Bare fields must be final; consider adding accessors")
+ if clazz.fullname in IGNORE_BARE_FIELDS:
+ pass
+ elif clazz.fullname.endswith("LayoutParams"):
+ pass
+ elif clazz.fullname.startswith("android.util.Mutable"):
+ pass
+ else:
+ error(clazz, f, "Bare fields must be marked final; consider adding accessors")
if not "static" in f.split:
if not re.match("[a-z]([a-zA-Z]+)?", f.name):
- error(clazz, f, "Non-static fields must be myName")
+ error(clazz, f, "Non-static fields must be named with myField style")
- if re.match("[m][A-Z]", f.name):
+ if re.match("[ms][A-Z]", f.name):
error(clazz, f, "Don't expose your internal objects")
+ if re.match("[A-Z_]+", f.name):
+ if "static" not in f.split or "final" not in f.split:
+ error(clazz, f, "Constants must be marked static final")
+
def verify_register(clazz):
"""Verify parity of registration methods.
@@ -353,34 +434,34 @@
if m.name.startswith("register"):
other = "unregister" + m.name[8:]
if other not in methods:
- error(clazz, m, "Missing unregister")
+ error(clazz, m, "Missing unregister method")
if m.name.startswith("unregister"):
other = "register" + m.name[10:]
if other not in methods:
- error(clazz, m, "Missing register")
+ error(clazz, m, "Missing register method")
if m.name.startswith("add") or m.name.startswith("remove"):
- error(clazz, m, "Callback should be register/unregister")
+ error(clazz, m, "Callback methods should be named register/unregister")
if "Listener" in m.raw:
if m.name.startswith("add"):
other = "remove" + m.name[3:]
if other not in methods:
- error(clazz, m, "Missing remove")
+ error(clazz, m, "Missing remove method")
if m.name.startswith("remove") and not m.name.startswith("removeAll"):
other = "add" + m.name[6:]
if other not in methods:
- error(clazz, m, "Missing add")
+ error(clazz, m, "Missing add method")
if m.name.startswith("register") or m.name.startswith("unregister"):
- error(clazz, m, "Listener should be add/remove")
+ error(clazz, m, "Listener methods should be named add/remove")
def verify_sync(clazz):
"""Verify synchronized methods aren't exposed."""
for m in clazz.methods:
if "synchronized" in m.split:
- error(clazz, m, "Lock exposed")
+ error(clazz, m, "Internal lock exposed")
def verify_intent_builder(clazz):
@@ -392,7 +473,7 @@
if m.name.startswith("create") and m.name.endswith("Intent"):
pass
else:
- warn(clazz, m, "Should be createFooIntent()")
+ error(clazz, m, "Methods creating an Intent should be named createFooIntent()")
def verify_helper_classes(clazz):
@@ -402,25 +483,57 @@
if "extends android.app.Service" in clazz.raw:
test_methods = True
if not clazz.name.endswith("Service"):
- error(clazz, None, "Inconsistent class name")
+ error(clazz, None, "Inconsistent class name; should be FooService")
+
+ found = False
+ for f in clazz.fields:
+ if f.name == "SERVICE_INTERFACE":
+ found = True
+ if f.value != clazz.fullname:
+ error(clazz, f, "Inconsistent interface constant; expected %s" % (clazz.fullname))
+
+ if not found:
+ warn(clazz, None, "Missing SERVICE_INTERFACE constant")
+
+ if "abstract" in clazz.split and not clazz.fullname.startswith("android.service."):
+ warn(clazz, None, "Services extended by developers should be under android.service")
+
if "extends android.content.ContentProvider" in clazz.raw:
test_methods = True
if not clazz.name.endswith("Provider"):
- error(clazz, None, "Inconsistent class name")
+ error(clazz, None, "Inconsistent class name; should be FooProvider")
+
+ found = False
+ for f in clazz.fields:
+ if f.name == "PROVIDER_INTERFACE":
+ found = True
+ if f.value != clazz.fullname:
+ error(clazz, f, "Inconsistent interface name; expected %s" % (clazz.fullname))
+
+ if not found:
+ warn(clazz, None, "Missing PROVIDER_INTERFACE constant")
+
+ if "abstract" in clazz.split and not clazz.fullname.startswith("android.provider."):
+ warn(clazz, None, "Providers extended by developers should be under android.provider")
+
if "extends android.content.BroadcastReceiver" in clazz.raw:
test_methods = True
if not clazz.name.endswith("Receiver"):
- error(clazz, None, "Inconsistent class name")
+ error(clazz, None, "Inconsistent class name; should be FooReceiver")
+
if "extends android.app.Activity" in clazz.raw:
test_methods = True
if not clazz.name.endswith("Activity"):
- error(clazz, None, "Inconsistent class name")
+ error(clazz, None, "Inconsistent class name; should be FooActivity")
if test_methods:
for m in clazz.methods:
if "final" in m.split: continue
if not re.match("on[A-Z]", m.name):
- error(clazz, m, "Extendable methods should be onFoo() style, otherwise final")
+ if "abstract" in m.split:
+ error(clazz, m, "Methods implemented by developers must be named onFoo()")
+ else:
+ warn(clazz, m, "If implemented by developer, should be named onFoo(); otherwise consider marking final")
def verify_builder(clazz):
@@ -430,7 +543,7 @@
if not clazz.name.endswith("Builder"): return
if clazz.name != "Builder":
- warn(clazz, None, "Should be standalone Builder class")
+ warn(clazz, None, "Builder should be defined as inner class")
has_build = False
for m in clazz.methods:
@@ -442,11 +555,11 @@
if m.name.startswith("clear"): continue
if m.name.startswith("with"):
- error(clazz, m, "Builder methods must be setFoo()")
+ error(clazz, m, "Builder methods names must follow setFoo() style")
if m.name.startswith("set"):
if not m.typ.endswith(clazz.fullname):
- warn(clazz, m, "Should return the builder")
+ warn(clazz, m, "Methods should return the builder")
if not has_build:
warn(clazz, None, "Missing build() method")
@@ -474,7 +587,7 @@
"android.view",
"android.animation",
"android.provider",
- "android.content",
+ ["android.content","android.graphics.drawable"],
"android.database",
"android.graphics",
"android.text",
@@ -508,29 +621,40 @@
warn(clazz, m, "Method argument type violates package layering")
-def verify_boolean(clazz):
+def verify_boolean(clazz, api):
"""Catches people returning boolean from getFoo() style methods.
Ignores when matching setFoo() is present."""
+
methods = [ m.name for m in clazz.methods ]
+
+ builder = clazz.fullname + ".Builder"
+ builder_methods = []
+ if builder in api:
+ builder_methods = [ m.name for m in api[builder].methods ]
+
for m in clazz.methods:
if m.typ == "boolean" and m.name.startswith("get") and m.name != "get" and len(m.args) == 0:
setter = "set" + m.name[3:]
- if setter not in methods:
- error(clazz, m, "Methods returning boolean should be isFoo or hasFoo")
+ if setter in methods:
+ pass
+ elif builder is not None and setter in builder_methods:
+ pass
+ else:
+ warn(clazz, m, "Methods returning boolean should be named isFoo, hasFoo, areFoo")
def verify_collections(clazz):
"""Verifies that collection types are interfaces."""
+ if clazz.fullname == "android.os.Bundle": return
+
bad = ["java.util.Vector", "java.util.LinkedList", "java.util.ArrayList", "java.util.Stack",
"java.util.HashMap", "java.util.HashSet", "android.util.ArraySet", "android.util.ArrayMap"]
for m in clazz.methods:
- filt = re.sub("<.+>", "", m.typ)
- if filt in bad:
- error(clazz, m, "Return type is concrete collection")
+ if m.typ in bad:
+ error(clazz, m, "Return type is concrete collection; should be interface")
for arg in m.args:
- filt = re.sub("<.+>", "", arg)
- if filt in bad:
- error(clazz, m, "Argument is concrete collection")
+ if arg in bad:
+ error(clazz, m, "Argument is concrete collection; should be interface")
def verify_flags(clazz):
@@ -545,15 +669,18 @@
scope = f.name[0:f.name.index("FLAG_")]
if val & known[scope]:
- warn(clazz, f, "Found overlapping flag")
+ warn(clazz, f, "Found overlapping flag constant value")
known[scope] |= val
-def verify_all(api):
+def verify_style(api):
+ """Find all style issues in the given API level."""
global failures
- failures = []
- for clazz in api:
+ failures = {}
+ for key in sorted(api.keys()):
+ clazz = api[key]
+
if clazz.pkg.name.startswith("java"): continue
if clazz.pkg.name.startswith("junit"): continue
if clazz.pkg.name.startswith("org.apache"): continue
@@ -581,26 +708,90 @@
verify_aidl(clazz)
verify_internal(clazz)
verify_layering(clazz)
- verify_boolean(clazz)
+ verify_boolean(clazz, api)
verify_collections(clazz)
verify_flags(clazz)
return failures
+def verify_compat(cur, prev):
+ """Find any incompatible API changes between two levels."""
+ global failures
+
+ def class_exists(api, test):
+ return test.fullname in api
+
+ def ctor_exists(api, clazz, test):
+ for m in clazz.ctors:
+ if m.ident == test.ident: return True
+ return False
+
+ def all_methods(api, clazz):
+ methods = list(clazz.methods)
+ if clazz.extends is not None:
+ methods.extend(all_methods(api, api[clazz.extends]))
+ return methods
+
+ def method_exists(api, clazz, test):
+ methods = all_methods(api, clazz)
+ for m in methods:
+ if m.ident == test.ident: return True
+ return False
+
+ def field_exists(api, clazz, test):
+ for f in clazz.fields:
+ if f.ident == test.ident: return True
+ return False
+
+ failures = {}
+ for key in sorted(prev.keys()):
+ prev_clazz = prev[key]
+
+ if not class_exists(cur, prev_clazz):
+ error(prev_clazz, None, "Class removed or incompatible change")
+ continue
+
+ cur_clazz = cur[key]
+
+ for test in prev_clazz.ctors:
+ if not ctor_exists(cur, cur_clazz, test):
+ error(prev_clazz, prev_ctor, "Constructor removed or incompatible change")
+
+ methods = all_methods(prev, prev_clazz)
+ for test in methods:
+ if not method_exists(cur, cur_clazz, test):
+ error(prev_clazz, test, "Method removed or incompatible change")
+
+ for test in prev_clazz.fields:
+ if not field_exists(cur, cur_clazz, test):
+ error(prev_clazz, test, "Field removed or incompatible change")
+
+ return failures
+
+
cur = parse_api(sys.argv[1])
-cur_fail = verify_all(cur)
+cur_fail = verify_style(cur)
if len(sys.argv) > 2:
prev = parse_api(sys.argv[2])
- prev_fail = verify_all(prev)
+ prev_fail = verify_style(prev)
# ignore errors from previous API level
for p in prev_fail:
if p in cur_fail:
- cur_fail.remove(p)
+ del cur_fail[p]
+
+ # look for compatibility issues
+ compat_fail = verify_compat(cur, prev)
+
+ print "%s API compatibility issues %s\n" % ((format(fg=WHITE, bg=BLUE, bold=True), format(reset=True)))
+ for f in sorted(compat_fail):
+ print compat_fail[f]
+ print
-for f in cur_fail:
- print f
+print "%s API style issues %s\n" % ((format(fg=WHITE, bg=BLUE, bold=True), format(reset=True)))
+for f in sorted(cur_fail):
+ print cur_fail[f]
print
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 74f2f65..1393bce 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -1000,6 +1000,7 @@
}
/** @hide */
+ @SystemApi
public boolean startScan(WorkSource workSource) {
try {
mService.startScan(null, workSource);
@@ -1073,6 +1074,7 @@
* @return false if not supported.
* @hide
*/
+ @SystemApi
public boolean isBatchedScanSupported() {
try {
return mService.isBatchedScanSupported();
@@ -1099,6 +1101,7 @@
* {@link BATCHED_SCAN_RESULTS_AVAILABLE_ACTION} is received.
* @hide
*/
+ @SystemApi
public List<BatchedScanResult> getBatchedScanResults() {
try {
return mService.getBatchedScanResults(mContext.getOpPackageName());