diff options
Diffstat (limited to 'core/java')
26 files changed, 393 insertions, 343 deletions
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index b4471f0..7994d7c 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -1092,6 +1092,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM reply.writeNoException(); return true; } + + case KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION: { + data.enforceInterface(IActivityManager.descriptor); + killAllBackgroundProcesses(); + reply.writeNoException(); + return true; + } case FORCE_STOP_PACKAGE_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); @@ -2906,7 +2913,7 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); reply.recycle(); } - + public void killBackgroundProcesses(String packageName) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); @@ -2917,7 +2924,17 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); reply.recycle(); } - + + public void killAllBackgroundProcesses() throws RemoteException { + Parcel data = Parcel.obtain(); + Parcel reply = Parcel.obtain(); + data.writeInterfaceToken(IActivityManager.descriptor); + mRemote.transact(KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION, data, reply, 0); + reply.readException(); + data.recycle(); + reply.recycle(); + } + public void forceStopPackage(String packageName) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 00fe953..a4714ca 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -3832,11 +3832,16 @@ public final class ActivityThread { * Initialize the default http proxy in this process for the reasons we set the time zone. */ IBinder b = ServiceManager.getService(Context.CONNECTIVITY_SERVICE); - IConnectivityManager service = IConnectivityManager.Stub.asInterface(b); - try { - ProxyProperties proxyProperties = service.getProxy(); - Proxy.setHttpProxySystemProperty(proxyProperties); - } catch (RemoteException e) {} + if (b != null) { + // In pre-boot mode (doing initial launch to collect password), not + // all system is up. This includes the connectivity service, so don't + // crash if we can't get it. + IConnectivityManager service = IConnectivityManager.Stub.asInterface(b); + try { + ProxyProperties proxyProperties = service.getProxy(); + Proxy.setHttpProxySystemProperty(proxyProperties); + } catch (RemoteException e) {} + } if (data.instrumentationName != null) { ContextImpl appContext = new ContextImpl(); diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java index 9b01b7f..473a2d1 100644 --- a/core/java/android/app/Fragment.java +++ b/core/java/android/app/Fragment.java @@ -458,6 +458,9 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene // have been started and their loaders are finished. boolean mDeferStart; + // Hint provided by the app that this fragment is currently visible to the user. + boolean mUserVisibleHint = true; + LoaderManagerImpl mLoaderManager; boolean mLoadersStarted; boolean mCheckedForLoaderManager; @@ -915,31 +918,32 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene } /** - * Set whether this fragment should enter the started state as normal or if - * start should be deferred until a system-determined convenient time, such - * as after any loaders have completed their work. + * Set a hint to the system about whether this fragment's UI is currently visible + * to the user. This hint defaults to true and is persistent across fragment instance + * state save and restore. * - * <p>This option is not sticky across fragment starts; after a deferred start - * completes this option will be set to false.</p> + * <p>An app may set this to false to indicate that the fragment's UI is + * scrolled out of visibility or is otherwise not directly visible to the user. + * This may be used by the system to prioritize operations such as fragment lifecycle updates + * or loader ordering behavior.</p> * - * @param deferResume true if this fragment can defer its resume until after others + * @param isVisibleToUser true if this fragment's UI is currently visible to the user (default), + * false if it is not. */ - public void setStartDeferred(boolean deferResume) { - if (mDeferStart && !deferResume) { + public void setUserVisibleHint(boolean isVisibleToUser) { + if (!mUserVisibleHint && isVisibleToUser && mState < STARTED) { mFragmentManager.performPendingDeferredStart(this); } - mDeferStart = deferResume; + mUserVisibleHint = isVisibleToUser; + mDeferStart = !isVisibleToUser; } /** - * Returns true if this fragment's move to the started state has been deferred. - * If this returns true it will be started once other fragments' loaders - * have finished running. - * - * @return true if this fragment's start has been deferred. + * @return The current value of the user-visible hint on this fragment. + * @see #setUserVisibleHint(boolean) */ - public boolean isStartDeferred() { - return mDeferStart; + public boolean getUserVisibleHint() { + return mUserVisibleHint; } /** @@ -1477,7 +1481,8 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene writer.print(" mMenuVisible="); writer.print(mMenuVisible); writer.print(" mHasMenu="); writer.println(mHasMenu); writer.print(prefix); writer.print("mRetainInstance="); writer.print(mRetainInstance); - writer.print(" mRetaining="); writer.println(mRetaining); + writer.print(" mRetaining="); writer.print(mRetaining); + writer.print(" mUserVisibleHint="); writer.println(mUserVisibleHint); if (mFragmentManager != null) { writer.print(prefix); writer.print("mFragmentManager="); writer.println(mFragmentManager); diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index c4ba778..a8c9cba 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -382,6 +382,7 @@ final class FragmentManagerImpl extends FragmentManager { static final String TARGET_REQUEST_CODE_STATE_TAG = "android:target_req_state"; static final String TARGET_STATE_TAG = "android:target_state"; static final String VIEW_STATE_TAG = "android:view_state"; + static final String USER_VISIBLE_HINT_TAG = "android:user_visible_hint"; ArrayList<Runnable> mPendingActions; Runnable[] mTmpActions; @@ -406,6 +407,7 @@ final class FragmentManagerImpl extends FragmentManager { boolean mStateSaved; boolean mDestroyed; String mNoTransactionsBecause; + boolean mHavePendingDeferredStart; // Temporary vars for state save and restore. Bundle mStateBundle = null; @@ -711,6 +713,11 @@ final class FragmentManagerImpl extends FragmentManager { public void performPendingDeferredStart(Fragment f) { if (f.mDeferStart) { + if (mExecutingActions) { + // Wait until we're done executing our pending transactions + mHavePendingDeferredStart = true; + return; + } f.mDeferStart = false; moveToState(f, mCurState, 0, 0); } @@ -757,6 +764,14 @@ final class FragmentManagerImpl extends FragmentManager { f.mTargetRequestCode = f.mSavedFragmentState.getInt( FragmentManagerImpl.TARGET_REQUEST_CODE_STATE_TAG, 0); } + f.mUserVisibleHint = f.mSavedFragmentState.getBoolean( + FragmentManagerImpl.USER_VISIBLE_HINT_TAG, true); + if (!f.mUserVisibleHint) { + f.mDeferStart = true; + if (newState > Fragment.STOPPED) { + newState = Fragment.STOPPED; + } + } } f.mActivity = mActivity; f.mFragmentManager = mActivity.mFragments; @@ -1343,7 +1358,7 @@ final class FragmentManagerImpl extends FragmentManager { synchronized (this) { if (mPendingActions == null || mPendingActions.size() == 0) { - return didSomething; + break; } numActions = mPendingActions.size(); @@ -1363,8 +1378,23 @@ final class FragmentManagerImpl extends FragmentManager { mExecutingActions = false; didSomething = true; } + + if (mHavePendingDeferredStart) { + boolean loadersRunning = false; + for (int i=0; i<mActive.size(); i++) { + Fragment f = mActive.get(i); + if (f != null && f.mLoaderManager != null) { + loadersRunning |= f.mLoaderManager.hasRunningLoaders(); + } + } + if (!loadersRunning) { + mHavePendingDeferredStart = false; + startPendingDeferredFragments(); + } + } + return didSomething; } - + void reportBackStackChanged() { if (mBackStackChangeListeners != null) { for (int i=0; i<mBackStackChangeListeners.size(); i++) { @@ -1500,6 +1530,10 @@ final class FragmentManagerImpl extends FragmentManager { result.putSparseParcelableArray( FragmentManagerImpl.VIEW_STATE_TAG, f.mSavedViewState); } + if (!f.mUserVisibleHint) { + // Only add this if it's not the default value + result.putBoolean(FragmentManagerImpl.USER_VISIBLE_HINT_TAG, f.mUserVisibleHint); + } return result; } diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index 26813bf..5222d37 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -234,6 +234,7 @@ public interface IActivityManager extends IInterface { public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException; public void killBackgroundProcesses(final String packageName) throws RemoteException; + public void killAllBackgroundProcesses() throws RemoteException; public void forceStopPackage(final String packageName) throws RemoteException; // Note: probably don't want to allow applications access to these. @@ -605,4 +606,5 @@ public interface IActivityManager extends IInterface { int GET_PROCESS_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+136; int SHOW_BOOT_MESSAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137; int DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+138; + int KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+139; } diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java index 761c7eb..61a9dce 100644 --- a/core/java/android/appwidget/AppWidgetHostView.java +++ b/core/java/android/appwidget/AppWidgetHostView.java @@ -26,6 +26,7 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; +import android.graphics.Rect; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; @@ -41,8 +42,8 @@ import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.FrameLayout; import android.widget.RemoteViews; -import android.widget.TextView; import android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback; +import android.widget.TextView; /** * Provides the glue to show AppWidget views. This class offers automatic animation @@ -106,7 +107,9 @@ public class AppWidgetHostView extends FrameLayout { } /** - * Set the AppWidget that will be displayed by this view. + * Set the AppWidget that will be displayed by this view. This method also adds default padding + * to widgets, as described in {@link #getDefaultPaddingForWidget(Context, ComponentName, Rect)} + * and can be overridden in order to add custom padding. */ public void setAppWidget(int appWidgetId, AppWidgetProviderInfo info) { mAppWidgetId = appWidgetId; @@ -116,49 +119,57 @@ public class AppWidgetHostView extends FrameLayout { // a widget, eg. for some widgets in safe mode. if (info != null) { // We add padding to the AppWidgetHostView if necessary - Padding padding = getPaddingForWidget(info.provider); + Rect padding = getDefaultPaddingForWidget(mContext, info.provider, null); setPadding(padding.left, padding.top, padding.right, padding.bottom); } } - private static class Padding { - int left = 0; - int right = 0; - int top = 0; - int bottom = 0; - } - /** * As of ICE_CREAM_SANDWICH we are automatically adding padding to widgets targeting * ICE_CREAM_SANDWICH and higher. The new widget design guidelines strongly recommend * that widget developers do not add extra padding to their widgets. This will help * achieve consistency among widgets. + * + * Note: this method is only needed by developers of AppWidgetHosts. The method is provided in + * order for the AppWidgetHost to account for the automatic padding when computing the number + * of cells to allocate to a particular widget. + * + * @param context the current context + * @param component the component name of the widget + * @param padding Rect in which to place the output, if null, a new Rect will be allocated and + * returned + * @return default padding for this widget */ - private Padding getPaddingForWidget(ComponentName component) { - PackageManager packageManager = mContext.getPackageManager(); - Padding p = new Padding(); + public static Rect getDefaultPaddingForWidget(Context context, ComponentName component, + Rect padding) { + PackageManager packageManager = context.getPackageManager(); ApplicationInfo appInfo; + if (padding == null) { + padding = new Rect(0, 0, 0, 0); + } else { + padding.set(0, 0, 0, 0); + } + try { appInfo = packageManager.getApplicationInfo(component.getPackageName(), 0); - } catch (Exception e) { + } catch (NameNotFoundException e) { // if we can't find the package, return 0 padding - return p; + return padding; } if (appInfo.targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - Resources r = getResources(); - p.left = r.getDimensionPixelSize(com.android.internal. + Resources r = context.getResources(); + padding.left = r.getDimensionPixelSize(com.android.internal. R.dimen.default_app_widget_padding_left); - p.right = r.getDimensionPixelSize(com.android.internal. + padding.right = r.getDimensionPixelSize(com.android.internal. R.dimen.default_app_widget_padding_right); - p.top = r.getDimensionPixelSize(com.android.internal. + padding.top = r.getDimensionPixelSize(com.android.internal. R.dimen.default_app_widget_padding_top); - p.bottom = r.getDimensionPixelSize(com.android.internal. + padding.bottom = r.getDimensionPixelSize(com.android.internal. R.dimen.default_app_widget_padding_bottom); } - - return p; + return padding; } public int getAppWidgetId() { diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index 4cb8220..0306521 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -247,13 +247,12 @@ public final class BluetoothDevice implements Parcelable { * has been fetched. This intent is sent only when the UUIDs of the remote * device are requested to be fetched using Service Discovery Protocol * <p> Always contains the extra field {@link #EXTRA_DEVICE} - * <p> Always contains the extra filed {@link #EXTRA_UUID} + * <p> Always contains the extra field {@link #EXTRA_UUID} * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive. - * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_UUID = - "android.bleutooth.device.action.UUID"; + "android.bluetooth.device.action.UUID"; /** * Broadcast Action: Indicates a failure to retrieve the name of a remote @@ -451,7 +450,6 @@ public final class BluetoothDevice implements Parcelable { * Used as an extra field in {@link #ACTION_UUID} intents, * Contains the {@link android.os.ParcelUuid}s of the remote device which * is a parcelable version of {@link UUID}. - * @hide */ public static final String EXTRA_UUID = "android.bluetooth.device.extra.UUID"; @@ -770,7 +768,18 @@ public final class BluetoothDevice implements Parcelable { return false; } - /** @hide */ + /** + * Returns the supported features (UUIDs) of the remote device. + * + * <p>This method does not start a service discovery procedure to retrieve the UUIDs + * from the remote device. Instead, the local cached copy of the service + * UUIDs are returned. + * <p>Use {@link #fetchUuidsWithSdp} if fresh UUIDs are desired. + * <p>Requires {@link android.Manifest.permission#BLUETOOTH}. + * + * @return the supported features (UUIDs) of the remote device, + * or null on error + */ public ParcelUuid[] getUuids() { try { return sService.getRemoteUuids(mAddress); @@ -779,18 +788,19 @@ public final class BluetoothDevice implements Parcelable { } /** - * Perform a SDP query on the remote device to get the UUIDs - * supported. This API is asynchronous and an Intent is sent, - * with the UUIDs supported by the remote end. If there is an error - * in getting the SDP records or if the process takes a long time, - * an Intent is sent with the UUIDs that is currently present in the - * cache. Clients should use the {@link #getUuids} to get UUIDs - * is SDP is not to be performed. + * Perform a service discovery on the remote device to get the UUIDs supported. + * + * <p>This API is asynchronous and {@link #ACTION_UUID} intent is sent, + * with the UUIDs supported by the remote end. If there is an error + * in getting the SDP records or if the process takes a long time, + * {@link #ACTION_UUID} intent is sent with the UUIDs that is currently + * present in the cache. Clients should use the {@link #getUuids} to get UUIDs + * if service discovery is not to be performed. + * <p>Requires {@link android.Manifest.permission#BLUETOOTH}. * - * @return False if the sanity check fails, True if the process + * @return False if the sanity check fails, True if the process * of initiating an ACL connection to the remote device * was started. - * @hide */ public boolean fetchUuidsWithSdp() { try { diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java index 5c6ef1a..3605652 100644 --- a/core/java/android/net/NetworkStats.java +++ b/core/java/android/net/NetworkStats.java @@ -165,6 +165,17 @@ public class NetworkStats implements Parcelable { dest.writeLongArray(operations); } + @Override + public NetworkStats clone() { + final NetworkStats clone = new NetworkStats(elapsedRealtime, size); + NetworkStats.Entry entry = null; + for (int i = 0; i < size; i++) { + entry = getValues(i, entry); + clone.addValues(entry); + } + return clone; + } + // @VisibleForTesting public NetworkStats addIfaceValues( String iface, long rxBytes, long rxPackets, long txBytes, long txPackets) { @@ -455,7 +466,7 @@ public class NetworkStats implements Parcelable { public NetworkStats subtract(NetworkStats value) throws NonMonotonicException { final long deltaRealtime = this.elapsedRealtime - value.elapsedRealtime; if (deltaRealtime < 0) { - throw new IllegalArgumentException("found non-monotonic realtime"); + throw new NonMonotonicException(this, value); } // result will have our rows, and elapsed time between snapshots @@ -575,7 +586,8 @@ public class NetworkStats implements Parcelable { pw.print("NetworkStats: elapsedRealtime="); pw.println(elapsedRealtime); for (int i = 0; i < size; i++) { pw.print(prefix); - pw.print(" iface="); pw.print(iface[i]); + pw.print(" ["); pw.print(i); pw.print("]"); + pw.print(" iface="); pw.print(iface[i]); pw.print(" uid="); pw.print(uid[i]); pw.print(" set="); pw.print(setToString(set[i])); pw.print(" tag="); pw.print(tagToString(tag[i])); @@ -638,6 +650,10 @@ public class NetworkStats implements Parcelable { public final int leftIndex; public final int rightIndex; + public NonMonotonicException(NetworkStats left, NetworkStats right) { + this(left, -1, right, -1); + } + public NonMonotonicException( NetworkStats left, int leftIndex, NetworkStats right, int rightIndex) { this.left = checkNotNull(left, "missing left"); diff --git a/core/java/android/net/wimax/WimaxManagerConstants.java b/core/java/android/net/wimax/WimaxManagerConstants.java new file mode 100644 index 0000000..b4aaf5b --- /dev/null +++ b/core/java/android/net/wimax/WimaxManagerConstants.java @@ -0,0 +1,104 @@ +package android.net.wimax; + +/** + * {@hide} + */ +public class WimaxManagerConstants +{ + + /** + * Used by android.net.wimax.WimaxManager for handling management of + * Wimax access. + */ + public static final String WIMAX_SERVICE = "WiMax"; + + /** + * Broadcast intent action indicating that Wimax has been enabled, disabled, + * enabling, disabling, or unknown. One extra provides this state as an int. + * Another extra provides the previous state, if available. + */ + public static final String NET_4G_STATE_CHANGED_ACTION = + "android.net.fourG.NET_4G_STATE_CHANGED"; + + /** + * The lookup key for an int that indicates whether Wimax is enabled, + * disabled, enabling, disabling, or unknown. + */ + public static final String EXTRA_WIMAX_STATUS = "wimax_status"; + + /** + * Broadcast intent action indicating that Wimax state has been changed + * state could be scanning, connecting, connected, disconnecting, disconnected + * initializing, initialized, unknown and ready. One extra provides this state as an int. + * Another extra provides the previous state, if available. + */ + public static final String WIMAX_NETWORK_STATE_CHANGED_ACTION = + "android.net.fourG.wimax.WIMAX_NETWORK_STATE_CHANGED"; + + /** + * Broadcast intent action indicating that Wimax signal level has been changed. + * Level varies from 0 to 3. + */ + public static final String SIGNAL_LEVEL_CHANGED_ACTION = + "android.net.wimax.SIGNAL_LEVEL_CHANGED"; + + /** + * The lookup key for an int that indicates whether Wimax state is + * scanning, connecting, connected, disconnecting, disconnected + * initializing, initialized, unknown and ready. + */ + public static final String EXTRA_WIMAX_STATE = "WimaxState"; + public static final String EXTRA_4G_STATE = "4g_state"; + public static final String EXTRA_WIMAX_STATE_INT = "WimaxStateInt"; + /** + * The lookup key for an int that indicates whether state of Wimax + * is idle. + */ + public static final String EXTRA_WIMAX_STATE_DETAIL = "WimaxStateDetail"; + + /** + * The lookup key for an int that indicates Wimax signal level. + */ + public static final String EXTRA_NEW_SIGNAL_LEVEL = "newSignalLevel"; + + /** + * Indicatates Wimax is disabled. + */ + public static final int NET_4G_STATE_DISABLED = 1; + + /** + * Indicatates Wimax is enabled. + */ + public static final int NET_4G_STATE_ENABLED = 3; + + /** + * Indicatates Wimax status is known. + */ + public static final int NET_4G_STATE_UNKNOWN = 4; + + /** + * Indicatates Wimax is in idle state. + */ + public static final int WIMAX_IDLE = 6; + + /** + * Indicatates Wimax is being deregistered. + */ + public static final int WIMAX_DEREGISTRATION = 8; + + /** + * Indicatates wimax state is unknown. + */ + public static final int WIMAX_STATE_UNKNOWN = 0; + + /** + * Indicatates wimax state is connected. + */ + public static final int WIMAX_STATE_CONNECTED = 7; + + /** + * Indicatates wimax state is disconnected. + */ + public static final int WIMAX_STATE_DISCONNECTED = 9; + +} diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index ff28596..821b6df 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -1673,7 +1673,6 @@ public final class ContactsContract { * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM * permission. * </p> - * @hide */ public static final class StreamItems implements StreamItemsColumns { /** @@ -2736,7 +2735,6 @@ public final class ContactsContract { * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM * permission. * </p> - * @hide */ public static final class StreamItems implements BaseColumns, StreamItemsColumns { /** @@ -3149,7 +3147,6 @@ public final class ContactsContract { * </pre> * </dd> * </dl> - * @hide */ public static final class StreamItems implements BaseColumns, StreamItemsColumns { /** @@ -3247,7 +3244,6 @@ public final class ContactsContract { * Columns in the StreamItems table. * * @see ContactsContract.StreamItems - * @hide */ protected interface StreamItemsColumns { /** @@ -3538,7 +3534,6 @@ public final class ContactsContract { * <pre> * </dd> * </dl> - * @hide */ public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns { /** @@ -3566,7 +3561,6 @@ public final class ContactsContract { * Columns in the StreamItemPhotos table. * * @see ContactsContract.StreamItemPhotos - * @hide */ protected interface StreamItemPhotosColumns { /** diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index a0652f7..769776e 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -1183,6 +1183,10 @@ public final class Settings { public static final String RADIO_WIFI = "wifi"; /** + * {@hide} + */ + public static final String RADIO_WIMAX = "wimax"; + /** * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio. */ public static final String RADIO_CELL = "cell"; @@ -2899,6 +2903,11 @@ public final class Settings { */ public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = "wifi_networks_available_notification_on"; + /** + * {@hide} + */ + public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON = + "wimax_networks_available_notification_on"; /** * Delay (in seconds) before repeating the Wi-Fi networks available notification. @@ -4068,6 +4077,13 @@ public final class Settings { "contacts_preauth_uri_expiration"; /** + * Whether the Messaging app posts notifications. + * 0=disabled. 1=enabled. + */ + public static final String MESSAGING_APP_NOTIFICATIONS = "messaging_app_notifications"; + + + /** * This are the settings to be backed up. * * NOTE: Settings are backed up and restored in the order they appear @@ -4104,7 +4120,8 @@ public final class Settings { MOUNT_UMS_NOTIFY_ENABLED, UI_NIGHT_MODE, LOCK_SCREEN_OWNER_INFO, - LOCK_SCREEN_OWNER_INFO_ENABLED + LOCK_SCREEN_OWNER_INFO_ENABLED, + MESSAGING_APP_NOTIFICATIONS }; /** diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 0e6d07d..8eb9da1 100755 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -1838,5 +1838,15 @@ public final class Telephony { public static final String EXTRA_PLMN = "plmn"; public static final String EXTRA_SHOW_SPN = "showSpn"; public static final String EXTRA_SPN = "spn"; + + /** + * Activity Action: Shows a dialog to turn off Messaging app notification. + * <p>Input: Nothing. + * <p>Output: Nothing. + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_MESSAGING_APP_NOTIFICATIONS = + "android.provider.Telephony.MESSAGING_APP_NOTIFICATIONS"; + } } diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java index 954a6fe..fdc2570 100755 --- a/core/java/android/speech/tts/TextToSpeech.java +++ b/core/java/android/speech/tts/TextToSpeech.java @@ -1089,6 +1089,7 @@ public class TextToSpeech { // Copy feature strings defined by the framework. copyStringParam(bundle, params, Engine.KEY_FEATURE_NETWORK_SYNTHESIS); + copyStringParam(bundle, params, Engine.KEY_FEATURE_EMBEDDED_SYNTHESIS); // Copy over all parameters that start with the name of the // engine that we are currently connected to. The engine is diff --git a/core/java/android/speech/tts/TextToSpeechService.java b/core/java/android/speech/tts/TextToSpeechService.java index 245271d..83b6d4c 100644 --- a/core/java/android/speech/tts/TextToSpeechService.java +++ b/core/java/android/speech/tts/TextToSpeechService.java @@ -792,8 +792,13 @@ public abstract class TextToSpeechService extends Service { public String[] getFeaturesForLanguage(String lang, String country, String variant) { Set<String> features = onGetFeaturesForLanguage(lang, country, variant); - String[] featuresArray = new String[features.size()]; - features.toArray(featuresArray); + String[] featuresArray = null; + if (features != null) { + featuresArray = new String[features.size()]; + features.toArray(featuresArray); + } else { + featuresArray = new String[0]; + } return featuresArray; } diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java index 2cc928f..388920c 100644 --- a/core/java/android/webkit/BrowserFrame.java +++ b/core/java/android/webkit/BrowserFrame.java @@ -813,8 +813,6 @@ class BrowserFrame extends Handler { boolean synchronous, String username, String password) { - PerfChecker checker = new PerfChecker(); - if (mSettings.getCacheMode() != WebSettings.LOAD_DEFAULT) { cacheMode = mSettings.getCacheMode(); } @@ -872,11 +870,6 @@ class BrowserFrame extends Handler { || headers.containsKey("If-None-Match") ? WebSettings.LOAD_NO_CACHE : cacheMode); // Set referrer to current URL? - if (!loader.executeLoad()) { - checker.responseAlert("startLoadingResource fail"); - } - checker.responseAlert("startLoadingResource succeed"); - return !synchronous ? loadListener : null; } diff --git a/core/java/android/webkit/JWebCoreJavaBridge.java b/core/java/android/webkit/JWebCoreJavaBridge.java index 5b78586..b498435 100644 --- a/core/java/android/webkit/JWebCoreJavaBridge.java +++ b/core/java/android/webkit/JWebCoreJavaBridge.java @@ -87,11 +87,9 @@ final class JWebCoreJavaBridge extends Handler { * Call native timer callbacks. */ private void fireSharedTimer() { - PerfChecker checker = new PerfChecker(); // clear the flag so that sharedTimerFired() can set a new timer mHasInstantTimer = false; sharedTimerFired(); - checker.responseAlert("sharedTimer"); } /** diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java index 04af738..37e8bc0 100644 --- a/core/java/android/webkit/LoadListener.java +++ b/core/java/android/webkit/LoadListener.java @@ -1136,7 +1136,6 @@ class LoadListener extends Handler implements EventHandler { // Give the data to WebKit now. We don't have to synchronize on // mDataBuilder here because pulling each chunk removes it from the // internal list so it cannot be modified. - PerfChecker checker = new PerfChecker(); ByteArrayBuilder.Chunk c; while (true) { c = mDataBuilder.getFirstChunk(); @@ -1152,7 +1151,6 @@ class LoadListener extends Handler implements EventHandler { } else { c.release(); } - checker.responseAlert("res nativeAddData"); } } @@ -1173,13 +1171,11 @@ class LoadListener extends Handler implements EventHandler { WebViewWorker.MSG_REMOVE_CACHE, this).sendToTarget(); } if (mNativeLoader != 0) { - PerfChecker checker = new PerfChecker(); if (!mSetNativeResponse) { setNativeResponse(); } nativeFinished(); - checker.responseAlert("res nativeFinished"); clearNativeLoader(); } } diff --git a/core/java/android/webkit/PerfChecker.java b/core/java/android/webkit/PerfChecker.java deleted file mode 100644 index 8c5f86e..0000000 --- a/core/java/android/webkit/PerfChecker.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.webkit; - -import android.os.SystemClock; -import android.util.Log; - -class PerfChecker { - - private long mTime; - private static final long mResponseThreshold = 2000; // 2s - - public PerfChecker() { - if (false) { - mTime = SystemClock.uptimeMillis(); - } - } - - /** - * @param what log string - * Logs given string if mResponseThreshold time passed between either - * instantiation or previous responseAlert call - */ - public void responseAlert(String what) { - if (false) { - long upTime = SystemClock.uptimeMillis(); - long time = upTime - mTime; - if (time > mResponseThreshold) { - Log.w("webkit", what + " used " + time + " ms"); - } - // Reset mTime, to permit reuse - mTime = upTime; - } - } -} diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index 5ee1b8a..8aafc3d 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -16,14 +16,9 @@ package android.webkit; -import com.android.internal.widget.EditableInputConnection; - import android.content.Context; -import android.graphics.Canvas; import android.graphics.Color; -import android.graphics.ColorFilter; import android.graphics.Paint; -import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; @@ -60,12 +55,12 @@ import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.TextView; +import junit.framework.Assert; + import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; -import junit.framework.Assert; - /** * WebTextView is a specialized version of EditText used by WebView * to overlay html textfields (and textareas) to use our standard @@ -926,18 +921,23 @@ import junit.framework.Assert; */ /* package */ void setRect(int x, int y, int width, int height) { LayoutParams lp = (LayoutParams) getLayoutParams(); + boolean needsUpdate = false; if (null == lp) { lp = new LayoutParams(width, height, x, y); } else { - lp.x = x; - lp.y = y; - lp.width = width; - lp.height = height; + if ((lp.x != x) || (lp.y != y) || (lp.width != width) + || (lp.height != height)) { + needsUpdate = true; + lp.x = x; + lp.y = y; + lp.width = width; + lp.height = height; + } } if (getParent() == null) { // Insert the view so that it's drawn first (at index 0) mWebView.addView(this, 0, lp); - } else { + } else if (needsUpdate) { setLayoutParams(lp); } // Set up a measure spec so a layout can always be recreated. diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 58b63fe..55f345f 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -683,7 +683,6 @@ public class WebView extends AbsoluteLayout private static final int SWITCH_TO_LONGPRESS = 4; private static final int RELEASE_SINGLE_TAP = 5; private static final int REQUEST_FORM_DATA = 6; - private static final int RESUME_WEBCORE_PRIORITY = 7; private static final int DRAG_HELD_MOTIONLESS = 8; private static final int AWAKEN_SCROLL_BARS = 9; private static final int PREVENT_DEFAULT_TIMEOUT = 10; @@ -2850,46 +2849,47 @@ public class WebView extends AbsoluteLayout // Used to avoid sending many visible rect messages. private Rect mLastVisibleRectSent; private Rect mLastGlobalRect; + private Rect mVisibleRect = new Rect(); + private Rect mGlobalVisibleRect = new Rect(); + private Point mScrollOffset = new Point(); Rect sendOurVisibleRect() { if (mZoomManager.isPreventingWebkitUpdates()) return mLastVisibleRectSent; - Rect rect = new Rect(); - calcOurContentVisibleRect(rect); + calcOurContentVisibleRect(mVisibleRect); // Rect.equals() checks for null input. - if (!rect.equals(mLastVisibleRectSent)) { + if (!mVisibleRect.equals(mLastVisibleRectSent)) { if (!mBlockWebkitViewMessages) { - Point pos = new Point(rect.left, rect.top); + mScrollOffset.set(mVisibleRect.left, mVisibleRect.top); mWebViewCore.removeMessages(EventHub.SET_SCROLL_OFFSET); mWebViewCore.sendMessage(EventHub.SET_SCROLL_OFFSET, - nativeMoveGeneration(), mSendScrollEvent ? 1 : 0, pos); + nativeMoveGeneration(), mSendScrollEvent ? 1 : 0, mScrollOffset); } - mLastVisibleRectSent = rect; + mLastVisibleRectSent = mVisibleRect; mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS); } - Rect globalRect = new Rect(); - if (getGlobalVisibleRect(globalRect) - && !globalRect.equals(mLastGlobalRect)) { + if (getGlobalVisibleRect(mGlobalVisibleRect) + && !mGlobalVisibleRect.equals(mLastGlobalRect)) { if (DebugFlags.WEB_VIEW) { - Log.v(LOGTAG, "sendOurVisibleRect=(" + globalRect.left + "," - + globalRect.top + ",r=" + globalRect.right + ",b=" - + globalRect.bottom); + Log.v(LOGTAG, "sendOurVisibleRect=(" + mGlobalVisibleRect.left + "," + + mGlobalVisibleRect.top + ",r=" + mGlobalVisibleRect.right + ",b=" + + mGlobalVisibleRect.bottom); } // TODO: the global offset is only used by windowRect() // in ChromeClientAndroid ; other clients such as touch // and mouse events could return view + screen relative points. if (!mBlockWebkitViewMessages) { - mWebViewCore.sendMessage(EventHub.SET_GLOBAL_BOUNDS, globalRect); + mWebViewCore.sendMessage(EventHub.SET_GLOBAL_BOUNDS, mGlobalVisibleRect); } - mLastGlobalRect = globalRect; + mLastGlobalRect = mGlobalVisibleRect; } - return rect; + return mVisibleRect; } + private Point mGlobalVisibleOffset = new Point(); // Sets r to be the visible rectangle of our webview in view coordinates private void calcOurVisibleRect(Rect r) { - Point p = new Point(); - getGlobalVisibleRect(r, p); - r.offset(-p.x, -p.y); + getGlobalVisibleRect(r, mGlobalVisibleOffset); + r.offset(-mGlobalVisibleOffset.x, -mGlobalVisibleOffset.y); } // Sets r to be our visible rectangle in content coordinates @@ -2905,21 +2905,21 @@ public class WebView extends AbsoluteLayout r.bottom = viewToContentY(r.bottom); } + private Rect mContentVisibleRect = new Rect(); // Sets r to be our visible rectangle in content coordinates. We use this // method on the native side to compute the position of the fixed layers. // Uses floating coordinates (necessary to correctly place elements when // the scale factor is not 1) private void calcOurContentVisibleRectF(RectF r) { - Rect ri = new Rect(0,0,0,0); - calcOurVisibleRect(ri); - r.left = viewToContentXf(ri.left); + calcOurVisibleRect(mContentVisibleRect); + r.left = viewToContentXf(mContentVisibleRect.left); // viewToContentY will remove the total height of the title bar. Add // the visible height back in to account for the fact that if the title // bar is partially visible, the part of the visible rect which is // displaying our content is displaced by that amount. - r.top = viewToContentYf(ri.top + getVisibleTitleHeightImpl()); - r.right = viewToContentXf(ri.right); - r.bottom = viewToContentYf(ri.bottom); + r.top = viewToContentYf(mContentVisibleRect.top + getVisibleTitleHeightImpl()); + r.right = viewToContentXf(mContentVisibleRect.right); + r.bottom = viewToContentYf(mContentVisibleRect.bottom); } static class ViewSizeData { @@ -3569,7 +3569,6 @@ public class WebView extends AbsoluteLayout mScrollingLayerRect.top = y; } abortAnimation(); - mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY); nativeSetIsScrolling(false); if (!mBlockWebkitViewMessages) { WebViewCore.resumePriority(); @@ -4119,20 +4118,6 @@ public class WebView extends AbsoluteLayout } private void drawContent(Canvas canvas, boolean drawRings) { - // Update the buttons in the picture, so when we draw the picture - // to the screen, they are in the correct state. - // Tell the native side if user is a) touching the screen, - // b) pressing the trackball down, or c) pressing the enter key - // If the cursor is on a button, we need to draw it in the pressed - // state. - // If mNativeClass is 0, we should not reach here, so we do not - // need to check it again. - boolean pressed = (mTouchMode == TOUCH_SHORTPRESS_START_MODE - || mTouchMode == TOUCH_INIT_MODE - || mTouchMode == TOUCH_SHORTPRESS_MODE); - recordButtons(canvas, - hasFocus() && hasWindowFocus(), (pressed && !USE_WEBKIT_RINGS) - || mTrackballDown || mGotCenterDown, false); drawCoreAndCursorRing(canvas, mBackgroundColor, mDrawCursorRing && drawRings); } @@ -5193,9 +5178,6 @@ public class WebView extends AbsoluteLayout mGotCenterDown = true; mPrivateHandler.sendMessageDelayed(mPrivateHandler .obtainMessage(LONG_PRESS_CENTER), LONG_PRESS_TIMEOUT); - // Already checked mNativeClass, so we do not need to check it - // again. - recordButtons(null, hasFocus() && hasWindowFocus(), true, true); if (!wantsKeyEvents) return true; } // Bubble up the key event as WebView doesn't handle it @@ -5631,9 +5613,6 @@ public class WebView extends AbsoluteLayout // drawing the cursor ring mDrawCursorRing = true; setFocusControllerActive(true); - if (mNativeClass != 0) { - recordButtons(null, true, false, true); - } } else { if (!inEditingMode()) { // If our window gained focus, but we do not have it, do not @@ -5659,9 +5638,6 @@ public class WebView extends AbsoluteLayout mKeysPressed.clear(); mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS); mTouchMode = TOUCH_DONE_MODE; - if (mNativeClass != 0) { - recordButtons(null, false, false, true); - } setFocusControllerActive(false); } invalidate(); @@ -5717,9 +5693,6 @@ public class WebView extends AbsoluteLayout // the cursor ring if (hasWindowFocus()) { mDrawCursorRing = true; - if (mNativeClass != 0) { - recordButtons(null, true, false, true); - } setFocusControllerActive(true); //} else { // The WebView has gained focus while we do not have @@ -5731,9 +5704,6 @@ public class WebView extends AbsoluteLayout // true if we are in editing mode), stop drawing the cursor ring. if (!inEditingMode()) { mDrawCursorRing = false; - if (mNativeClass != 0) { - recordButtons(null, false, false, true); - } setFocusControllerActive(false); } mKeysPressed.clear(); @@ -6021,7 +5991,6 @@ public class WebView extends AbsoluteLayout mScroller.abortAnimation(); mTouchMode = TOUCH_DRAG_START_MODE; mConfirmMove = true; - mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY); nativeSetIsScrolling(false); } else if (mPrivateHandler.hasMessages(RELEASE_SINGLE_TAP)) { mPrivateHandler.removeMessages(RELEASE_SINGLE_TAP); @@ -6847,7 +6816,6 @@ public class WebView extends AbsoluteLayout if (mNativeClass == 0) { return false; } - recordButtons(null, hasFocus() && hasWindowFocus(), true, true); if (time - mLastCursorTime <= TRACKBALL_TIMEOUT && !mLastCursorBounds.equals(nativeGetCursorRingBounds())) { nativeSelectBestAt(mLastCursorBounds); @@ -7359,7 +7327,6 @@ public class WebView extends AbsoluteLayout mLastTouchTime = eventTime; if (!mScroller.isFinished()) { abortAnimation(); - mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY); } mSnapScrollMode = SNAP_NONE; mVelocityTracker = VelocityTracker.obtain(); @@ -8491,10 +8458,6 @@ public class WebView extends AbsoluteLayout mWebTextView.setAdapterCustom(adapter); } break; - case RESUME_WEBCORE_PRIORITY: - WebViewCore.resumePriority(); - WebViewCore.resumeUpdatePicture(mWebViewCore); - break; case LONG_PRESS_CENTER: // as this is shared by keydown and trackballdown, reset all @@ -9442,24 +9405,6 @@ public class WebView extends AbsoluteLayout return nativeTileProfilingGetFloat(frame, tile, key); } - /** - * Helper method to deal with differences between hardware and software rendering - */ - private void recordButtons(Canvas canvas, boolean focus, boolean pressed, - boolean inval) { - boolean isHardwareAccel = canvas != null - ? canvas.isHardwareAccelerated() - : isHardwareAccelerated(); - if (isHardwareAccel) { - // We never want to change button state if we are hardware accelerated, - // but we DO want to invalidate as necessary so that the GL ring - // can be drawn - nativeRecordButtons(mNativeClass, false, false, inval); - } else { - nativeRecordButtons(mNativeClass, focus, pressed, inval); - } - } - private native int nativeCacheHitFramePointer(); private native boolean nativeCacheHitIsPlugin(); private native Rect nativeCacheHitNodeBounds(); @@ -9556,8 +9501,6 @@ public class WebView extends AbsoluteLayout private native boolean nativePointInNavCache(int x, int y, int slop); // Like many other of our native methods, you must make sure that // mNativeClass is not null before calling this method. - private native void nativeRecordButtons(int nativeInstance, - boolean focused, boolean pressed, boolean invalidate); private native void nativeResetSelection(); private native Point nativeSelectableText(); private native void nativeSelectAll(); diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index 5ab99dc..1a1b8d0 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -741,9 +741,16 @@ public class NumberPicker extends LinearLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final int newWidthMeasureSpec = makeMeasureSpec(widthMeasureSpec, mMinWidth, mMaxWidth); - final int newHeightMeasureSpec = makeMeasureSpec(heightMeasureSpec, mMinHeight, mMaxHeight); + // Try greedily to fit the max width and height. + final int newWidthMeasureSpec = makeMeasureSpec(widthMeasureSpec, mMaxWidth); + final int newHeightMeasureSpec = makeMeasureSpec(heightMeasureSpec, mMaxHeight); super.onMeasure(newWidthMeasureSpec, newHeightMeasureSpec); + // Flag if we are measured with width or height less than the respective min. + final int desiredWidth = Math.max(mMinWidth, getMeasuredWidth()); + final int desiredHeight = Math.max(mMinHeight, getMeasuredHeight()); + final int widthSize = resolveSizeAndState(desiredWidth, newWidthMeasureSpec, 0); + final int heightSize = resolveSizeAndState(desiredHeight, newHeightMeasureSpec, 0); + setMeasuredDimension(widthSize, heightSize); } @Override @@ -1357,23 +1364,19 @@ public class NumberPicker extends LinearLayout { * Makes a measure spec that tries greedily to use the max value. * * @param measureSpec The measure spec. - * @param maxValue The max value for the size. + * @param maxSize The max value for the size. * @return A measure spec greedily imposing the max size. */ - private int makeMeasureSpec(int measureSpec, int minValue, int maxValue) { + private int makeMeasureSpec(int measureSpec, int maxSize) { final int size = MeasureSpec.getSize(measureSpec); - if (size < minValue) { - throw new IllegalArgumentException("Available space is less than min size: " - + size + " < " + minValue); - } final int mode = MeasureSpec.getMode(measureSpec); switch (mode) { case MeasureSpec.EXACTLY: return measureSpec; case MeasureSpec.AT_MOST: - return MeasureSpec.makeMeasureSpec(Math.min(size, maxValue), MeasureSpec.EXACTLY); + return MeasureSpec.makeMeasureSpec(Math.min(size, maxSize), MeasureSpec.EXACTLY); case MeasureSpec.UNSPECIFIED: - return MeasureSpec.makeMeasureSpec(maxValue, MeasureSpec.EXACTLY); + return MeasureSpec.makeMeasureSpec(maxSize, MeasureSpec.EXACTLY); default: throw new IllegalArgumentException("Unknown measure mode: " + mode); } diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index e84ae97..f524ef0 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -728,7 +728,8 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { private void updateSubmitButton(boolean hasText) { int visibility = GONE; - if (isSubmitAreaEnabled() && hasFocus() && (hasText || !mVoiceButtonEnabled)) { + if (mSubmitButtonEnabled && isSubmitAreaEnabled() && hasFocus() + && (hasText || !mVoiceButtonEnabled)) { visibility = VISIBLE; } mSubmitButton.setVisibility(visibility); @@ -1082,9 +1083,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { CharSequence text = mQueryTextView.getText(); mUserQuery = text; boolean hasText = !TextUtils.isEmpty(text); - if (isSubmitButtonEnabled()) { - updateSubmitButton(hasText); - } + updateSubmitButton(hasText); updateVoiceButton(!hasText); updateCloseButton(); updateSubmitArea(); diff --git a/core/java/android/widget/SpellChecker.java b/core/java/android/widget/SpellChecker.java index e929e7d..87c3e9b 100644 --- a/core/java/android/widget/SpellChecker.java +++ b/core/java/android/widget/SpellChecker.java @@ -82,6 +82,8 @@ public class SpellChecker implements SpellCheckerSessionListener { } private void setLocale(Locale locale) { + closeSession(); + final TextServicesManager textServicesManager = (TextServicesManager) mTextView.getContext().getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE); if (!textServicesManager.isSpellCheckerEnabled()) { @@ -104,12 +106,6 @@ public class SpellChecker implements SpellCheckerSessionListener { // Change SpellParsers' wordIterator locale mWordIterator = new WordIterator(locale); - // Stop all SpellParsers - final int length = mSpellParsers.length; - for (int i = 0; i < length; i++) { - mSpellParsers[i].finish(); - } - // Remove existing misspelled SuggestionSpans mTextView.removeMisspelledSpans((Editable) mTextView.getText()); diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index 27d44bf..ec3790e 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -68,6 +68,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { int mDropDownWidth; private int mGravity; + private boolean mDisableChildrenWhenDisabled; private Rect mTempRect = new Rect(); @@ -186,6 +187,9 @@ public class Spinner extends AbsSpinner implements OnClickListener { mPopup.setPromptText(a.getString(com.android.internal.R.styleable.Spinner_prompt)); + mDisableChildrenWhenDisabled = a.getBoolean( + com.android.internal.R.styleable.Spinner_disableChildrenWhenDisabled, false); + a.recycle(); // Base constructor can call setAdapter before we initialize mPopup. @@ -196,6 +200,17 @@ public class Spinner extends AbsSpinner implements OnClickListener { } } + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (mDisableChildrenWhenDisabled) { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + getChildAt(i).setEnabled(enabled); + } + } + } + /** * Describes how the selected item view is positioned. Currently only the horizontal component * is used. The default is determined by the current theme. @@ -398,6 +413,9 @@ public class Spinner extends AbsSpinner implements OnClickListener { addViewInLayout(child, 0, lp); child.setSelected(hasFocus()); + if (mDisableChildrenWhenDisabled) { + child.setEnabled(isEnabled()); + } // Get measure specs int childHeightSpec = ViewGroup.getChildMeasureSpec(mHeightMeasureSpec, diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index a8680d4..5833afd 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -9059,51 +9059,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener sendAccessibilityEventUnchecked(event); } - @Override - protected void onCreateContextMenu(ContextMenu menu) { - super.onCreateContextMenu(menu); - boolean added = false; - mContextMenuTriggeredByKey = mDPadCenterIsDown || mEnterKeyIsDown; - // Problem with context menu on long press: the menu appears while the key in down and when - // the key is released, the view does not receive the key_up event. - // We need two layers of flags: mDPadCenterIsDown and mEnterKeyIsDown are set in key down/up - // events. We cannot simply clear these flags in onTextContextMenuItem since - // it may not be called (if the user/ discards the context menu with the back key). - // We clear these flags here and mContextMenuTriggeredByKey saves that state so that it is - // available in onTextContextMenuItem. - mDPadCenterIsDown = mEnterKeyIsDown = false; - - MenuHandler handler = new MenuHandler(); - - if (mText instanceof Spanned && hasSelectionController()) { - long lastTouchOffset = getLastTouchOffsets(); - final int selStart = extractRangeStartFromLong(lastTouchOffset); - final int selEnd = extractRangeEndFromLong(lastTouchOffset); - - URLSpan[] urls = ((Spanned) mText).getSpans(selStart, selEnd, URLSpan.class); - if (urls.length > 0) { - menu.add(0, ID_COPY_URL, 0, com.android.internal.R.string.copyUrl). - setOnMenuItemClickListener(handler); - - added = true; - } - } - - // The context menu is not empty, which will prevent the selection mode from starting. - // Add a entry to start it in the context menu. - // TODO Does not handle the case where a subclass does not call super.thisMethod or - // populates the menu AFTER this call. - if (menu.size() > 0) { - menu.add(0, ID_SELECTION_MODE, 0, com.android.internal.R.string.selectTextMode). - setOnMenuItemClickListener(handler); - added = true; - } - - if (added) { - menu.setHeaderTitle(com.android.internal.R.string.editTextMenuTitle); - } - } - /** * Returns whether this text view is a current input method target. The * default implementation just checks with {@link InputMethodManager}. @@ -9118,9 +9073,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private static final int ID_CUT = android.R.id.cut; private static final int ID_COPY = android.R.id.copy; private static final int ID_PASTE = android.R.id.paste; - // Context menu entries - private static final int ID_COPY_URL = android.R.id.copyUrl; - private static final int ID_SELECTION_MODE = android.R.id.selectTextMode; private class MenuHandler implements MenuItem.OnMenuItemClickListener { public boolean onMenuItemClick(MenuItem item) { @@ -9130,9 +9082,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Called when a context menu option for the text view is selected. Currently - * this will be {@link android.R.id#copyUrl}, {@link android.R.id#selectTextMode}, - * {@link android.R.id#selectAll}, {@link android.R.id#paste}, {@link android.R.id#cut} - * or {@link android.R.id#copy}. + * this will be one of {@link android.R.id#selectAll}, {@link android.R.id#cut}, + * {@link android.R.id#copy} or {@link android.R.id#paste}. * * @return true if the context menu item action was performed. */ @@ -9149,34 +9100,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } switch (id) { - case ID_COPY_URL: - URLSpan[] urls = ((Spanned) mText).getSpans(min, max, URLSpan.class); - if (urls.length >= 1) { - ClipData clip = null; - for (int i=0; i<urls.length; i++) { - Uri uri = Uri.parse(urls[0].getURL()); - if (clip == null) { - clip = ClipData.newRawUri(null, uri); - } else { - clip.addItem(new ClipData.Item(uri)); - } - } - if (clip != null) { - setPrimaryClip(clip); - } - } - stopSelectionActionMode(); - return true; - - case ID_SELECTION_MODE: - if (mSelectionActionMode != null) { - // Selection mode is already started, simply change selected part. - selectCurrentWord(); - } else { - startSelectionActionMode(); - } - return true; - case ID_SELECT_ALL: // This does not enter text selection mode. Text is highlighted, so that it can be // bulk edited, like selectAllOnFocus does. Returns true even if text is empty. diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index d5450e4..17b8acf 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -439,17 +439,6 @@ public class LockPatternUtils { } /** - * Calls back SetupFaceLock to save the temporary gallery file if this is the backup lock. - * This doesn't have to verify that biometric is enabled because it's only called in that case - */ - void moveTempGallery() { - Intent intent = new Intent().setClassName("com.android.facelock", - "com.android.facelock.SetupFaceLock"); - intent.putExtra("moveTempGallery", true); - mContext.startActivity(intent); - } - - /** * Calls back SetupFaceLock to delete the temporary gallery file */ public void deleteTempGallery() { @@ -501,8 +490,7 @@ public class LockPatternUtils { setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK); setLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); - setBoolean(BIOMETRIC_WEAK_EVER_CHOSEN_KEY, true); - moveTempGallery(); + finishBiometricWeak(); } dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, pattern .size(), 0, 0, 0, 0, 0, 0); @@ -619,8 +607,7 @@ public class LockPatternUtils { } else { setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK); setLong(PASSWORD_TYPE_ALTERNATE_KEY, Math.max(quality, computedQuality)); - setBoolean(BIOMETRIC_WEAK_EVER_CHOSEN_KEY, true); - moveTempGallery(); + finishBiometricWeak(); } if (computedQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) { int letters = 0; @@ -1087,4 +1074,16 @@ public class LockPatternUtils { } return false; } + + private void finishBiometricWeak() { + setBoolean(BIOMETRIC_WEAK_EVER_CHOSEN_KEY, true); + + // Launch intent to show final screen, this also + // moves the temporary gallery to the actual gallery + Intent intent = new Intent(); + intent.setClassName("com.android.facelock", + "com.android.facelock.SetupEndScreen"); + mContext.startActivity(intent); + } + } |
