Commits

Stephen Smalley committed ccfc108 Merge

Merge branch 'master' into seandroid

Comments (0)

Files changed (6)

core/java/android/database/sqlite/SQLiteConnection.java

 import android.util.LruCache;
 import android.util.Printer;
 
-import java.sql.Date;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.Map;
 import java.util.regex.Pattern;
 

core/java/android/text/format/DateFormat.java

 import java.util.TimeZone;
 import java.text.SimpleDateFormat;
 
+import libcore.icu.ICU;
 import libcore.icu.LocaleData;
 
 /**
      * Gets the current date format stored as a char array. The array will contain
      * 3 elements ({@link #DATE}, {@link #MONTH}, and {@link #YEAR}) in the order
      * specified by the user's format preference.  Note that this order is
-     * only appropriate for all-numeric dates; spelled-out (MEDIUM and LONG)
+     * <i>only</i> appropriate for all-numeric dates; spelled-out (MEDIUM and LONG)
      * dates will generally contain other punctuation, spaces, or words,
      * not just the day, month, and year, and not necessarily in the same
      * order returned here.
      */
     public static char[] getDateFormatOrder(Context context) {
-        char[] order = new char[] {DATE, MONTH, YEAR};
-        String value = getDateFormatString(context);
-        int index = 0;
-        boolean foundDate = false;
-        boolean foundMonth = false;
-        boolean foundYear = false;
-
-        for (char c : value.toCharArray()) {
-            if (!foundDate && (c == DATE)) {
-                foundDate = true;
-                order[index] = DATE;
-                index++;
-            }
-
-            if (!foundMonth && (c == MONTH || c == STANDALONE_MONTH)) {
-                foundMonth = true;
-                order[index] = MONTH;
-                index++;
-            }
-
-            if (!foundYear && (c == YEAR)) {
-                foundYear = true;
-                order[index] = YEAR;
-                index++;
-            }
-        }
-        return order;
+        return ICU.getDateFormatOrder(getDateFormatString(context));
     }
 
     private static String getDateFormatString(Context context) {

core/java/android/widget/DatePicker.java

 import android.os.Parcel;
 import android.os.Parcelable;
 import android.text.TextUtils;
+import android.text.InputType;
 import android.text.format.DateFormat;
 import android.text.format.DateUtils;
 import android.util.AttributeSet;
 
 import com.android.internal.R;
 
+import java.text.DateFormatSymbols;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Locale;
 import java.util.TimeZone;
 
+import libcore.icu.ICU;
+
 /**
  * This class is a widget for selecting a date. The date can be selected by a
  * year, month, and day spinners or a {@link CalendarView}. The set of spinners
         mCurrentDate = getCalendarForLocale(mCurrentDate, locale);
 
         mNumberOfMonths = mTempDate.getActualMaximum(Calendar.MONTH) + 1;
-        mShortMonths = new String[mNumberOfMonths];
-        for (int i = 0; i < mNumberOfMonths; i++) {
-            mShortMonths[i] = DateUtils.getMonthString(Calendar.JANUARY + i,
-                    DateUtils.LENGTH_MEDIUM);
+        mShortMonths = new DateFormatSymbols().getShortMonths();
+
+        if (usingNumericMonths()) {
+            // We're in a locale where a date should either be all-numeric, or all-text.
+            // All-text would require custom NumberPicker formatters for day and year.
+            mShortMonths = new String[mNumberOfMonths];
+            for (int i = 0; i < mNumberOfMonths; ++i) {
+                mShortMonths[i] = String.format("%d", i + 1);
+            }
         }
     }
 
     /**
+     * Tests whether the current locale is one where there are no real month names,
+     * such as Chinese, Japanese, or Korean locales.
+     */
+    private boolean usingNumericMonths() {
+        return Character.isDigit(mShortMonths[Calendar.JANUARY].charAt(0));
+    }
+
+    /**
      * Gets a calendar for locale bootstrapped with the value of a given calendar.
      *
      * @param oldCalendar The old calendar.
      */
     private void reorderSpinners() {
         mSpinners.removeAllViews();
-        char[] order = DateFormat.getDateFormatOrder(getContext());
+        // We use numeric spinners for year and day, but textual months. Ask icu4c what
+        // order the user's locale uses for that combination. http://b/7207103.
+        String pattern = ICU.getBestDateTimePattern("yyyyMMMdd", Locale.getDefault().toString());
+        char[] order = ICU.getDateFormatOrder(pattern);
         final int spinnerCount = order.length;
         for (int i = 0; i < spinnerCount; i++) {
             switch (order[i]) {
-                case DateFormat.DATE:
+                case 'd':
                     mSpinners.addView(mDaySpinner);
                     setImeOptions(mDaySpinner, spinnerCount, i);
                     break;
-                case DateFormat.MONTH:
+                case 'M':
                     mSpinners.addView(mMonthSpinner);
                     setImeOptions(mMonthSpinner, spinnerCount, i);
                     break;
-                case DateFormat.YEAR:
+                case 'y':
                     mSpinners.addView(mYearSpinner);
                     setImeOptions(mYearSpinner, spinnerCount, i);
                     break;
                 default:
-                    throw new IllegalArgumentException();
+                    throw new IllegalArgumentException(Arrays.toString(order));
             }
         }
     }
         mYearSpinner.setValue(mCurrentDate.get(Calendar.YEAR));
         mMonthSpinner.setValue(mCurrentDate.get(Calendar.MONTH));
         mDaySpinner.setValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
+
+        if (usingNumericMonths()) {
+            mMonthSpinnerInput.setRawInputType(InputType.TYPE_CLASS_NUMBER);
+        }
     }
 
     /**

core/java/android/widget/HeaderViewListAdapter.java

     }
 
     public boolean isEnabled(int position) {
-        // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
+        // Header (negative positions will throw an IndexOutOfBoundsException)
         int numHeaders = getHeadersCount();
         if (position < numHeaders) {
             return mHeaderViewInfos.get(position).isSelectable;
             }
         }
 
-        // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
+        // Footer (off-limits positions will throw an IndexOutOfBoundsException)
         return mFooterViewInfos.get(adjPosition - adapterCount).isSelectable;
     }
 
     public Object getItem(int position) {
-        // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
+        // Header (negative positions will throw an IndexOutOfBoundsException)
         int numHeaders = getHeadersCount();
         if (position < numHeaders) {
             return mHeaderViewInfos.get(position).data;
             }
         }
 
-        // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
+        // Footer (off-limits positions will throw an IndexOutOfBoundsException)
         return mFooterViewInfos.get(adjPosition - adapterCount).data;
     }
 
     }
 
     public View getView(int position, View convertView, ViewGroup parent) {
-        // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
+        // Header (negative positions will throw an IndexOutOfBoundsException)
         int numHeaders = getHeadersCount();
         if (position < numHeaders) {
             return mHeaderViewInfos.get(position).view;
             }
         }
 
-        // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
+        // Footer (off-limits positions will throw an IndexOutOfBoundsException)
         return mFooterViewInfos.get(adjPosition - adapterCount).view;
     }
 

keystore/java/android/security/KeyChain.java

             List<X509Certificate> chain = store
                     .getCertificateChain(toCertificate(certificateBytes));
             return chain.toArray(new X509Certificate[chain.size()]);
+        } catch (CertificateException e) {
+            throw new KeyChainException(e);
         } catch (RemoteException e) {
             throw new KeyChainException(e);
         } catch (RuntimeException e) {

wifi/java/android/net/wifi/WifiStateMachine.java

                     if (!isWifiTethered(stateChange.active)) {
                         loge("Tethering reports wifi as untethered!, shut down soft Ap");
                         setWifiApEnabled(null, false);
+                        setWifiApEnabled(null, true);
                     }
                     return HANDLED;
                 case CMD_STOP_AP:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.