diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/MediaRouteButton.java | 13 | ||||
| -rw-r--r-- | core/java/android/app/StatusBarManager.java | 33 | ||||
| -rw-r--r-- | core/java/android/content/Intent.java | 8 | ||||
| -rw-r--r-- | core/java/android/content/pm/VerificationParams.java | 71 | ||||
| -rwxr-xr-x | core/java/android/provider/ContactsContract.java | 86 | ||||
| -rw-r--r-- | core/java/android/provider/Settings.java | 13 | ||||
| -rw-r--r-- | core/java/android/view/ScaleGestureDetector.java | 22 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 138 | ||||
| -rw-r--r-- | core/java/android/view/ViewDebug.java | 12 | ||||
| -rw-r--r-- | core/java/android/view/ViewGroup.java | 64 | ||||
| -rw-r--r-- | core/java/android/widget/Gallery.java | 18 | ||||
| -rw-r--r-- | core/java/android/widget/NumberPicker.java | 8 | ||||
| -rw-r--r-- | core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java | 22 | ||||
| -rw-r--r-- | core/java/com/android/internal/statusbar/IStatusBar.aidl | 7 | ||||
| -rw-r--r-- | core/java/com/android/internal/statusbar/IStatusBarService.aidl | 7 |
15 files changed, 334 insertions, 188 deletions
diff --git a/core/java/android/app/MediaRouteButton.java b/core/java/android/app/MediaRouteButton.java index cfc8bbd..a9ccef0 100644 --- a/core/java/android/app/MediaRouteButton.java +++ b/core/java/android/app/MediaRouteButton.java @@ -221,21 +221,28 @@ public class MediaRouteButton extends View { void updateRouteCount() { final int N = mRouter.getRouteCount(); int count = 0; + boolean hasVideoRoutes = false; for (int i = 0; i < N; i++) { final RouteInfo route = mRouter.getRouteAt(i); - if ((route.getSupportedTypes() & mRouteTypes) != 0) { + final int routeTypes = route.getSupportedTypes(); + if ((routeTypes & mRouteTypes) != 0) { if (route instanceof RouteGroup) { count += ((RouteGroup) route).getRouteCount(); } else { count++; } + if ((routeTypes & MediaRouter.ROUTE_TYPE_LIVE_VIDEO) != 0) { + hasVideoRoutes = true; + } } } setEnabled(count != 0); - // Only allow toggling if we have more than just user routes - mToggleMode = count == 2 && (mRouteTypes & MediaRouter.ROUTE_TYPE_LIVE_AUDIO) != 0; + // Only allow toggling if we have more than just user routes. + // Don't toggle if we support video routes, we may have to let the dialog scan. + mToggleMode = count == 2 && (mRouteTypes & MediaRouter.ROUTE_TYPE_LIVE_AUDIO) != 0 && + !hasVideoRoutes; } @Override diff --git a/core/java/android/app/StatusBarManager.java b/core/java/android/app/StatusBarManager.java index 1e61e10..3d656c7 100644 --- a/core/java/android/app/StatusBarManager.java +++ b/core/java/android/app/StatusBarManager.java @@ -97,13 +97,13 @@ public class StatusBarManager { } /** - * Expand the notifications. + * Expand the notifications panel. */ - public void expandNotifications() { + public void expandNotificationsPanel() { try { final IStatusBarService svc = getService(); if (svc != null) { - svc.expandNotifications(); + svc.expandNotificationsPanel(); } } catch (RemoteException ex) { // system process is dead anyway. @@ -112,13 +112,13 @@ public class StatusBarManager { } /** - * Collapse the notifications. + * Collapse the notifications and settings panels. */ - public void collapseNotifications() { + public void collapsePanels() { try { final IStatusBarService svc = getService(); if (svc != null) { - svc.collapseNotifications(); + svc.collapsePanels(); } } catch (RemoteException ex) { // system process is dead anyway. @@ -127,28 +127,13 @@ public class StatusBarManager { } /** - * Expand the quick settings. + * Expand the settings panel. */ - public void expandQuickSettings() { + public void expandSettingsPanel() { try { final IStatusBarService svc = getService(); if (svc != null) { - svc.expandQuickSettings(); - } - } catch (RemoteException ex) { - // system process is dead anyway. - throw new RuntimeException(ex); - } - } - - /** - * Collapse the quick settings. - */ - public void collapseQuickSettings() { - try { - final IStatusBarService svc = getService(); - if (svc != null) { - svc.collapseQuickSettings(); + svc.expandSettingsPanel(); } } catch (RemoteException ex) { // system process is dead anyway. diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index b9518b8..c301c5c 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -1305,6 +1305,14 @@ public class Intent implements Parcelable, Cloneable { = "android.intent.extra.REFERRER"; /** + * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and + * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install + * @hide + */ + public static final String EXTRA_ORIGINATING_UID + = "android.intent.extra.ORIGINATING_UID"; + + /** * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a * package. Tells the installer UI to skip the confirmation with the user * if the .apk is replacing an existing one. diff --git a/core/java/android/content/pm/VerificationParams.java b/core/java/android/content/pm/VerificationParams.java index 6454de0..22e1a85 100644 --- a/core/java/android/content/pm/VerificationParams.java +++ b/core/java/android/content/pm/VerificationParams.java @@ -27,6 +27,9 @@ import android.os.Parcelable; * @hide */ public class VerificationParams implements Parcelable { + /** A constant used to indicate that a uid value is not present. */ + public static final int NO_UID = -1; + /** What we print out first when toString() is called. */ private static final String TO_STRING_PREFIX = "VerificationParams{"; @@ -39,6 +42,9 @@ public class VerificationParams implements Parcelable { /** HTTP referrer URI associated with the originatingURI. */ private final Uri mReferrer; + /** UID of the application that the install request originated from. */ + private final int mOriginatingUid; + /** UID of application requesting the install */ private int mInstallerUid; @@ -57,16 +63,19 @@ public class VerificationParams implements Parcelable { * from. May be {@code null}. * @param referrer HTTP referrer URI associated with the originatingURI. * May be {@code null}. + * @param originatingUid UID of the application that the install request originated + * from, or NO_UID if not present * @param manifestDigest an object that holds the digest of the package * which can be used to verify ownership. May be {@code null}. */ public VerificationParams(Uri verificationURI, Uri originatingURI, Uri referrer, - ManifestDigest manifestDigest) { + int originatingUid, ManifestDigest manifestDigest) { mVerificationURI = verificationURI; mOriginatingURI = originatingURI; mReferrer = referrer; + mOriginatingUid = originatingUid; mManifestDigest = manifestDigest; - mInstallerUid = -1; + mInstallerUid = NO_UID; } public Uri getVerificationURI() { @@ -81,11 +90,16 @@ public class VerificationParams implements Parcelable { return mReferrer; } + /** return NO_UID if not available */ + public int getOriginatingUid() { + return mOriginatingUid; + } + public ManifestDigest getManifestDigest() { return mManifestDigest; } - /** @return -1 when not set */ + /** @return NO_UID when not set */ public int getInstallerUid() { return mInstallerUid; } @@ -111,31 +125,39 @@ public class VerificationParams implements Parcelable { final VerificationParams other = (VerificationParams) o; - if (mVerificationURI == null && other.mVerificationURI != null) { - return false; - } - if (!mVerificationURI.equals(other.mVerificationURI)) { + if (mVerificationURI == null) { + if (other.mVerificationURI != null) { + return false; + } + } else if (!mVerificationURI.equals(other.mVerificationURI)) { return false; } - if (mOriginatingURI == null && other.mOriginatingURI != null) { - return false; - } - if (!mOriginatingURI.equals(other.mOriginatingURI)) { + if (mOriginatingURI == null) { + if (other.mOriginatingURI != null) { + return false; + } + } else if (!mOriginatingURI.equals(other.mOriginatingURI)) { return false; } - if (mReferrer == null && other.mReferrer != null) { - return false; - } - if (!mReferrer.equals(other.mReferrer)) { + if (mReferrer == null) { + if (other.mReferrer != null) { + return false; + } + } else if (!mReferrer.equals(other.mReferrer)) { return false; } - if (mManifestDigest == null && other.mManifestDigest != null) { + if (mOriginatingUid != other.mOriginatingUid) { return false; } - if (mManifestDigest != null && !mManifestDigest.equals(other.mManifestDigest)) { + + if (mManifestDigest == null) { + if (other.mManifestDigest != null) { + return false; + } + } else if (!mManifestDigest.equals(other.mManifestDigest)) { return false; } @@ -150,11 +172,12 @@ public class VerificationParams implements Parcelable { public int hashCode() { int hash = 3; - hash += 5 * (mVerificationURI==null?1:mVerificationURI.hashCode()); - hash += 7 * (mOriginatingURI==null?1:mOriginatingURI.hashCode()); - hash += 11 * (mReferrer==null?1:mReferrer.hashCode()); - hash += 13 * (mManifestDigest==null?1:mManifestDigest.hashCode()); - hash += 17 * mInstallerUid; + hash += 5 * (mVerificationURI == null ? 1 : mVerificationURI.hashCode()); + hash += 7 * (mOriginatingURI == null ? 1 : mOriginatingURI.hashCode()); + hash += 11 * (mReferrer == null ? 1 : mReferrer.hashCode()); + hash += 13 * mOriginatingUid; + hash += 17 * (mManifestDigest == null ? 1 : mManifestDigest.hashCode()); + hash += 19 * mInstallerUid; return hash; } @@ -169,6 +192,8 @@ public class VerificationParams implements Parcelable { sb.append(mOriginatingURI.toString()); sb.append(",mReferrer="); sb.append(mReferrer.toString()); + sb.append(",mOriginatingUid="); + sb.append(mOriginatingUid); sb.append(",mManifestDigest="); sb.append(mManifestDigest.toString()); sb.append(",mInstallerUid="); @@ -183,6 +208,7 @@ public class VerificationParams implements Parcelable { dest.writeParcelable(mVerificationURI, 0); dest.writeParcelable(mOriginatingURI, 0); dest.writeParcelable(mReferrer, 0); + dest.writeInt(mOriginatingUid); dest.writeParcelable(mManifestDigest, 0); dest.writeInt(mInstallerUid); } @@ -192,6 +218,7 @@ public class VerificationParams implements Parcelable { mVerificationURI = source.readParcelable(Uri.class.getClassLoader()); mOriginatingURI = source.readParcelable(Uri.class.getClassLoader()); mReferrer = source.readParcelable(Uri.class.getClassLoader()); + mOriginatingUid = source.readInt(); mManifestDigest = source.readParcelable(ManifestDigest.class.getClassLoader()); mInstallerUid = source.readInt(); } diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index b3ab385..5b49ba3 100755 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -7659,6 +7659,54 @@ public final class ContactsContract { public static final int MODE_LARGE = 3; /** + * Constructs the QuickContacts intent with a view's rect. + * @hide + */ + public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, + int mode, String[] excludeMimes) { + // Find location and bounds of target view, adjusting based on the + // assumed local density. + final float appScale = context.getResources().getCompatibilityInfo().applicationScale; + final int[] pos = new int[2]; + target.getLocationOnScreen(pos); + + final Rect rect = new Rect(); + rect.left = (int) (pos[0] * appScale + 0.5f); + rect.top = (int) (pos[1] * appScale + 0.5f); + rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); + rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); + + return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); + } + + /** + * Constructs the QuickContacts intent. + * @hide + */ + public static Intent composeQuickContactsIntent(Context context, Rect target, + Uri lookupUri, int mode, String[] excludeMimes) { + // When launching from an Activiy, we don't want to start a new task, but otherwise + // we *must* start a new task. (Otherwise startActivity() would crash.) + Context actualContext = context; + while ((actualContext instanceof ContextWrapper) + && !(actualContext instanceof Activity)) { + actualContext = ((ContextWrapper) actualContext).getBaseContext(); + } + final int intentFlags = (actualContext instanceof Activity) + ? Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET + : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK; + + // Launch pivot dialog through intent for now + final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); + + intent.setData(lookupUri); + intent.setSourceBounds(target); + intent.putExtra(EXTRA_MODE, mode); + intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); + return 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 @@ -7683,20 +7731,10 @@ public final class ContactsContract { */ public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, String[] excludeMimes) { - // Find location and bounds of target view, adjusting based on the - // assumed local density. - final float appScale = context.getResources().getCompatibilityInfo().applicationScale; - final int[] pos = new int[2]; - target.getLocationOnScreen(pos); - - final Rect rect = new Rect(); - rect.left = (int) (pos[0] * appScale + 0.5f); - rect.top = (int) (pos[1] * appScale + 0.5f); - rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); - rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); - // Trigger with obtained rectangle - showQuickContact(context, rect, lookupUri, mode, excludeMimes); + Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, + excludeMimes); + context.startActivity(intent); } /** @@ -7727,25 +7765,9 @@ public final class ContactsContract { */ public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, String[] excludeMimes) { - // When launching from an Activiy, we don't want to start a new task, but otherwise - // we *must* start a new task. (Otherwise startActivity() would crash.) - Context actualContext = context; - while ((actualContext instanceof ContextWrapper) - && !(actualContext instanceof Activity)) { - actualContext = ((ContextWrapper) actualContext).getBaseContext(); - } - final int intentFlags = (actualContext instanceof Activity) - ? Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET - : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK; - - // Launch pivot dialog through intent for now - final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); - - intent.setData(lookupUri); - intent.setSourceBounds(target); - intent.putExtra(EXTRA_MODE, mode); - intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); - context.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT)); + Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, + excludeMimes); + context.startActivity(intent); } } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 550713d..8825f58 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3141,6 +3141,12 @@ public final class Settings { public static final String DEVICE_PROVISIONED = Global.DEVICE_PROVISIONED; /** + * Whether the current user has been set up via setup wizard (0 = false, 1 = true) + * @hide + */ + public static final String USER_SETUP_COMPLETE = "user_setup_complete"; + + /** * List of input methods that are currently enabled. This is a string * containing the IDs of all enabled input methods, each ID separated * by ':'. @@ -4619,13 +4625,6 @@ public final class Settings { public static final String SMS_SHORT_CODE_RULE = "sms_short_code_rule"; /** - * Prefix for SMS short code regex patterns (country code is appended). - * @see com.android.internal.telephony.SmsUsageMonitor - * @hide - */ - public static final String SMS_SHORT_CODES_PREFIX = "sms_short_codes_"; - - /** * Used to disable Tethering on a device - defaults to true * @hide */ diff --git a/core/java/android/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java index b0a2711..4873860 100644 --- a/core/java/android/view/ScaleGestureDetector.java +++ b/core/java/android/view/ScaleGestureDetector.java @@ -19,6 +19,7 @@ package android.view; import android.content.Context; import android.os.SystemClock; import android.util.FloatMath; +import android.util.Log; import java.util.Arrays; @@ -223,10 +224,14 @@ public class ScaleGestureDetector { * @param id pointer id to clear * @see #addTouchHistory(MotionEvent) */ - private void removeTouchHistoryForId(int id) { + private boolean removeTouchHistoryForId(int id) { + if (id >= mTouchHistoryLastAccepted.length) { + return false; + } mTouchHistoryLastAccepted[id] = Float.NaN; mTouchHistoryDirection[id] = 0; mTouchHistoryLastAcceptedTime[id] = 0; + return true; } /** @@ -236,6 +241,11 @@ public class ScaleGestureDetector { * @see #addTouchHistory(MotionEvent) */ private float getAdjustedTouchHistory(int id) { + if (id >= mTouchHistoryLastAccepted.length) { + Log.e(TAG, "Error retrieving adjusted touch history for id=" + id + + " - incomplete event stream?"); + return 0; + } return mTouchHistoryLastAccepted[id]; } @@ -244,6 +254,10 @@ public class ScaleGestureDetector { * @see #addTouchHistory(MotionEvent) */ private void clearTouchHistory() { + if (mTouchHistoryLastAccepted == null) { + // All three arrays will be null if this is the case; nothing to do. + return; + } Arrays.fill(mTouchHistoryLastAccepted, Float.NaN); Arrays.fill(mTouchHistoryDirection, 0); Arrays.fill(mTouchHistoryLastAcceptedTime, 0); @@ -333,7 +347,11 @@ public class ScaleGestureDetector { final float focusY = sumY / div; if (pointerUp) { - removeTouchHistoryForId(event.getPointerId(event.getActionIndex())); + final int id = event.getPointerId(event.getActionIndex()); + if (!removeTouchHistoryForId(id)) { + Log.e(TAG, "Got ACTION_POINTER_UP for previously unknown id=" + id + + " - incomplete event stream?"); + } } else { addTouchHistory(event); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 111f959..f9ff865 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5887,6 +5887,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * layout attribute and/or the inherited value from the parent * * @return true if the layout is right-to-left. + * + * @hide */ @ViewDebug.ExportedProperty(category = "layout") public boolean isLayoutRtl() { @@ -11628,9 +11630,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * Resolve and cache the layout direction. LTR is set initially. This is implicitly supposing * that the parent directionality can and will be resolved before its children. * + * @return true if resolution has been done, false otherwise. + * * @hide */ - public void resolveLayoutDirection() { + public boolean resolveLayoutDirection() { // Clear any previous layout direction resolution mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK; @@ -11641,15 +11645,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, case LAYOUT_DIRECTION_INHERIT: // We cannot resolve yet. LTR is by default and let the resolution happen again // later to get the correct resolved value - if (!canResolveLayoutDirection()) return; - - ViewGroup viewGroup = ((ViewGroup) mParent); + if (!canResolveLayoutDirection()) return false; - // We cannot resolve yet on the parent too. LTR is by default and let the - // resolution happen again later - if (!viewGroup.canResolveLayoutDirection()) return; + View parent = ((View) mParent); + // Parent has not yet resolved, LTR is still the default + if (!parent.isLayoutDirectionResolved()) return false; - if (viewGroup.getLayoutDirection() == LAYOUT_DIRECTION_RTL) { + if (parent.getLayoutDirection() == LAYOUT_DIRECTION_RTL) { mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL; } break; @@ -11669,6 +11671,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // Set to resolved mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED; + return true; } /** @@ -11679,10 +11682,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @hide */ public boolean canResolveLayoutDirection() { - switch ((mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_MASK) >> - PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) { + switch (getRawLayoutDirection()) { case LAYOUT_DIRECTION_INHERIT: - return (mParent != null) && (mParent instanceof ViewGroup); + return (mParent != null) && (mParent instanceof ViewGroup) && + ((ViewGroup) mParent).canResolveLayoutDirection(); default: return true; } @@ -16640,9 +16643,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Resolve the text direction. * + * @return true if resolution has been done, false otherwise. + * * @hide */ - public void resolveTextDirection() { + public boolean resolveTextDirection() { // Reset any previous text direction resolution mPrivateFlags2 &= ~(PFLAG2_TEXT_DIRECTION_RESOLVED | PFLAG2_TEXT_DIRECTION_RESOLVED_MASK); @@ -16651,29 +16656,35 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final int textDirection = getRawTextDirection(); switch(textDirection) { case TEXT_DIRECTION_INHERIT: - if (canResolveTextDirection()) { - ViewGroup viewGroup = ((ViewGroup) mParent); - - // Set current resolved direction to the same value as the parent's one - final int parentResolvedDirection = viewGroup.getTextDirection(); - switch (parentResolvedDirection) { - case TEXT_DIRECTION_FIRST_STRONG: - case TEXT_DIRECTION_ANY_RTL: - case TEXT_DIRECTION_LTR: - case TEXT_DIRECTION_RTL: - case TEXT_DIRECTION_LOCALE: - mPrivateFlags2 |= - (parentResolvedDirection << PFLAG2_TEXT_DIRECTION_RESOLVED_MASK_SHIFT); - break; - default: - // Default resolved direction is "first strong" heuristic - mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; - } - } else { + if (!canResolveTextDirection()) { // We cannot do the resolution if there is no parent, so use the default one mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; // Resolution will need to happen again later - return; + return false; + } + + View parent = ((View) mParent); + // Parent has not yet resolved, so we still return the default + if (!parent.isTextDirectionResolved()) { + mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; + // Resolution will need to happen again later + return false; + } + + // Set current resolved direction to the same value as the parent's one + final int parentResolvedDirection = parent.getTextDirection(); + switch (parentResolvedDirection) { + case TEXT_DIRECTION_FIRST_STRONG: + case TEXT_DIRECTION_ANY_RTL: + case TEXT_DIRECTION_LTR: + case TEXT_DIRECTION_RTL: + case TEXT_DIRECTION_LOCALE: + mPrivateFlags2 |= + (parentResolvedDirection << PFLAG2_TEXT_DIRECTION_RESOLVED_MASK_SHIFT); + break; + default: + // Default resolved direction is "first strong" heuristic + mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; } break; case TEXT_DIRECTION_FIRST_STRONG: @@ -16695,6 +16706,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // Set to resolved mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED; + return true; } /** @@ -16705,7 +16717,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private boolean canResolveTextDirection() { switch (getRawTextDirection()) { case TEXT_DIRECTION_INHERIT: - return (mParent != null) && (mParent instanceof ViewGroup); + return (mParent != null) && (mParent instanceof View) && + ((View) mParent).canResolveTextDirection(); default: return true; } @@ -16835,9 +16848,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Resolve the text alignment. * + * @return true if resolution has been done, false otherwise. + * * @hide */ - public void resolveTextAlignment() { + public boolean resolveTextAlignment() { // Reset any previous text alignment resolution mPrivateFlags2 &= ~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK); @@ -16847,32 +16862,37 @@ public class View implements Drawable.Callback, KeyEvent.Callback, switch (textAlignment) { case TEXT_ALIGNMENT_INHERIT: // Check if we can resolve the text alignment - if (canResolveTextAlignment() && mParent instanceof View) { - View view = (View) mParent; - - final int parentResolvedTextAlignment = view.getTextAlignment(); - switch (parentResolvedTextAlignment) { - case TEXT_ALIGNMENT_GRAVITY: - case TEXT_ALIGNMENT_TEXT_START: - case TEXT_ALIGNMENT_TEXT_END: - case TEXT_ALIGNMENT_CENTER: - case TEXT_ALIGNMENT_VIEW_START: - case TEXT_ALIGNMENT_VIEW_END: - // Resolved text alignment is the same as the parent resolved - // text alignment - mPrivateFlags2 |= - (parentResolvedTextAlignment << PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT); - break; - default: - // Use default resolved text alignment - mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; - } - } - else { + if (!canResolveTextAlignment()) { // We cannot do the resolution if there is no parent so use the default mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; // Resolution will need to happen again later - return; + return false; + } + View parent = (View) mParent; + + // Parent has not yet resolved, so we still return the default + if (!parent.isTextAlignmentResolved()) { + mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; + // Resolution will need to happen again later + return false; + } + + final int parentResolvedTextAlignment = parent.getTextAlignment(); + switch (parentResolvedTextAlignment) { + case TEXT_ALIGNMENT_GRAVITY: + case TEXT_ALIGNMENT_TEXT_START: + case TEXT_ALIGNMENT_TEXT_END: + case TEXT_ALIGNMENT_CENTER: + case TEXT_ALIGNMENT_VIEW_START: + case TEXT_ALIGNMENT_VIEW_END: + // Resolved text alignment is the same as the parent resolved + // text alignment + mPrivateFlags2 |= + (parentResolvedTextAlignment << PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT); + break; + default: + // Use default resolved text alignment + mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; } break; case TEXT_ALIGNMENT_GRAVITY: @@ -16895,6 +16915,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // Set the resolved mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED; + return true; } /** @@ -16905,7 +16926,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private boolean canResolveTextAlignment() { switch (getRawTextAlignment()) { case TEXT_DIRECTION_INHERIT: - return (mParent != null); + return (mParent != null) && (mParent instanceof View) && + ((View) mParent).canResolveTextAlignment(); default: return true; } diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java index 1286eb9..c013d85 100644 --- a/core/java/android/view/ViewDebug.java +++ b/core/java/android/view/ViewDebug.java @@ -1178,10 +1178,14 @@ public class ViewDebug { private static void writeValue(BufferedWriter out, Object value) throws IOException { if (value != null) { - String output = value.toString().replace("\n", "\\n"); - out.write(String.valueOf(output.length())); - out.write(","); - out.write(output); + String output = "[EXCEPTION]"; + try { + output = value.toString().replace("\n", "\\n"); + } finally { + out.write(String.valueOf(output.length())); + out.write(","); + out.write(output); + } } else { out.write("4,null"); } diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 41890d6..db1c00a 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -3382,6 +3382,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager ai.mKeepScreenOn = lastKeepOn; } + if (child.isLayoutDirectionInherited()) { + child.resetResolvedLayoutDirection(); + child.resolveRtlPropertiesIfNeeded(); + } + onViewAdded(child); if ((child.mViewFlags & DUPLICATE_PARENT_STATE) == DUPLICATE_PARENT_STATE) { @@ -5256,48 +5261,54 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * @hide */ @Override - public void resolveLayoutDirection() { - super.resolveLayoutDirection(); - - int count = getChildCount(); - for (int i = 0; i < count; i++) { - final View child = getChildAt(i); - if (child.isLayoutDirectionInherited()) { - child.resolveLayoutDirection(); + public boolean resolveLayoutDirection() { + final boolean result = super.resolveLayoutDirection(); + if (result) { + int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.isLayoutDirectionInherited()) { + child.resolveLayoutDirection(); + } } } + return result; } /** * @hide */ @Override - public void resolveTextDirection() { - super.resolveTextDirection(); - - int count = getChildCount(); - for (int i = 0; i < count; i++) { - final View child = getChildAt(i); - if (child.isTextDirectionInherited()) { - child.resolveTextDirection(); + public boolean resolveTextDirection() { + final boolean result = super.resolveTextDirection(); + if (result) { + int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.isTextDirectionInherited()) { + child.resolveTextDirection(); + } } } + return result; } /** * @hide */ @Override - public void resolveTextAlignment() { - super.resolveTextAlignment(); - - int count = getChildCount(); - for (int i = 0; i < count; i++) { - final View child = getChildAt(i); - if (child.isTextAlignmentInherited()) { - child.resolveTextAlignment(); + public boolean resolveTextAlignment() { + final boolean result = super.resolveTextAlignment(); + if (result) { + int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.isTextAlignmentInherited()) { + child.resolveTextAlignment(); + } } } + return result; } /** @@ -5893,7 +5904,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } } - protected boolean isLayoutRtl() { + /** + * @hide + */ + public boolean isLayoutRtl() { return (layoutDirection == View.LAYOUT_DIRECTION_RTL); } diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java index b72b8cb..e0c5bbd 100644 --- a/core/java/android/widget/Gallery.java +++ b/core/java/android/widget/Gallery.java @@ -182,6 +182,12 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList */ private boolean mIsRtl = true; + /** + * Offset between the center of the selected child view and the center of the Gallery. + * Used to reset position correctly during layout. + */ + private int mSelectedCenterOffset; + public Gallery(Context context) { this(context, null); } @@ -395,6 +401,14 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList setSelectionToCenterChild(); + final View selChild = mSelectedChild; + if (selChild != null) { + final int childLeft = selChild.getLeft(); + final int childCenter = selChild.getWidth() / 2; + final int galleryCenter = getWidth() / 2; + mSelectedCenterOffset = childLeft + childCenter - galleryCenter; + } + onScrollChanged(0, 0, 0, 0); // dummy values, View's implementation does not use these. invalidate(); @@ -537,6 +551,7 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList // We haven't been callbacking during the fling, so do it now super.selectionChanged(); } + mSelectedCenterOffset = 0; invalidate(); } @@ -650,7 +665,8 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList View sel = makeAndAddView(mSelectedPosition, 0, 0, true); // Put the selected child in the center - int selectedOffset = childrenLeft + (childrenWidth / 2) - (sel.getWidth() / 2); + int selectedOffset = childrenLeft + (childrenWidth / 2) - (sel.getWidth() / 2) + + mSelectedCenterOffset; sel.offsetLeftAndRight(selectedOffset); fillToGalleryRight(); diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index 704f6b6..4918e48 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -1361,6 +1361,14 @@ public class NumberPicker extends LinearLayout { // Allow text entry rather than strictly numeric entry. mInputText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); + // Make sure the min, max, respect the size of the displayed + // values. This will take care of the current value as well. + if (getMinValue() >= displayedValues.length) { + setMinValue(0); + } + if (getMaxValue() >= displayedValues.length) { + setMaxValue(displayedValues.length - 1); + } } else { mInputText.setRawInputType(InputType.TYPE_CLASS_NUMBER); } diff --git a/core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java b/core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java index f010d7b..386f387 100644 --- a/core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java +++ b/core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java @@ -25,7 +25,7 @@ import android.app.MediaRouteActionProvider; import android.app.MediaRouteButton; import android.content.Context; import android.graphics.drawable.Drawable; -import android.media.AudioManager; +import android.hardware.display.DisplayManager; import android.media.MediaRouter; import android.media.MediaRouter.RouteCategory; import android.media.MediaRouter.RouteGroup; @@ -70,6 +70,7 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { }; MediaRouter mRouter; + DisplayManager mDisplayService; private int mRouteTypes; private LayoutInflater mInflater; @@ -97,6 +98,7 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { public void onAttach(Activity activity) { super.onAttach(activity); mRouter = (MediaRouter) activity.getSystemService(Context.MEDIA_ROUTER_SERVICE); + mDisplayService = (DisplayManager) activity.getSystemService(Context.DISPLAY_SERVICE); } @Override @@ -119,6 +121,15 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { public void setRouteTypes(int types) { mRouteTypes = types; + if ((mRouteTypes & MediaRouter.ROUTE_TYPE_LIVE_VIDEO) != 0 && mDisplayService == null) { + final Context activity = getActivity(); + if (activity != null) { + mDisplayService = (DisplayManager) activity.getSystemService( + Context.DISPLAY_SERVICE); + } + } else { + mDisplayService = null; + } } void updateVolume() { @@ -194,6 +205,9 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { @Override public void onResume() { super.onResume(); + if (mDisplayService != null) { + mDisplayService.scanWifiDisplays(); + } } private static class ViewHolder { @@ -253,7 +267,9 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { final RouteCategory cat = mRouter.getCategoryAt(i); routes = cat.getRoutes(mCatRouteList); - mItems.add(cat); + if (!cat.isSystem()) { + mItems.add(cat); + } if (cat == mCategoryEditingGroups) { addGroupEditingCategoryRoutes(routes); @@ -370,6 +386,7 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { public boolean isEnabled(int position) { switch (getItemViewType(position)) { case VIEW_ROUTE: + return ((RouteInfo) mItems.get(position)).isEnabled(); case VIEW_GROUPING_ROUTE: case VIEW_GROUPING_DONE: return true; @@ -434,6 +451,7 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { } convertView.setActivated(position == mSelectedItemPosition); + convertView.setEnabled(isEnabled(position)); return convertView; } diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index 0737b52..780f5b3 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -28,10 +28,9 @@ oneway interface IStatusBar void updateNotification(IBinder key, in StatusBarNotification notification); void removeNotification(IBinder key); void disable(int state); - void animateExpandNotifications(); - void animateCollapseNotifications(); - void animateExpandQuickSettings(); - void animateCollapseQuickSettings(); + void animateExpandNotificationsPanel(); + void animateExpandSettingsPanel(); + void animateCollapsePanels(); void setSystemUiVisibility(int vis, int mask); void topAppWindowChanged(boolean menuVisible); void setImeWindowStatus(in IBinder token, int vis, int backDisposition); diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index 60e2b34..600c27a 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -24,16 +24,15 @@ import com.android.internal.statusbar.StatusBarNotification; /** @hide */ interface IStatusBarService { - void expandNotifications(); - void collapseNotifications(); - void expandQuickSettings(); - void collapseQuickSettings(); + void expandNotificationsPanel(); + void collapsePanels(); void disable(int what, IBinder token, String pkg); void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription); void setIconVisibility(String slot, boolean visible); void removeIcon(String slot); void topAppWindowChanged(boolean menuVisible); void setImeWindowStatus(in IBinder token, int vis, int backDisposition); + void expandSettingsPanel(); // ---- Methods below are for use by the status bar policy services ---- // You need the STATUS_BAR_SERVICE permission |
