diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/annotation/SdkConstant.java | 2 | ||||
-rw-r--r-- | core/java/android/app/ActivityThread.java | 15 | ||||
-rw-r--r-- | core/java/android/app/ApplicationThreadNative.java | 15 | ||||
-rw-r--r-- | core/java/android/app/IApplicationThread.java | 2 | ||||
-rw-r--r-- | core/java/android/bluetooth/package.html | 90 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 12 | ||||
-rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 15 | ||||
-rw-r--r-- | core/java/android/widget/TextView.java | 5 | ||||
-rw-r--r-- | core/res/AndroidManifest.xml | 8 |
9 files changed, 70 insertions, 94 deletions
diff --git a/core/java/android/annotation/SdkConstant.java b/core/java/android/annotation/SdkConstant.java index 6ac70f0..0a53186 100644 --- a/core/java/android/annotation/SdkConstant.java +++ b/core/java/android/annotation/SdkConstant.java @@ -29,7 +29,7 @@ import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.SOURCE) public @interface SdkConstant { public static enum SdkConstantType { - ACTIVITY_INTENT_ACTION, BROADCAST_INTENT_ACTION, SERVICE_ACTION, INTENT_CATEGORY; + ACTIVITY_INTENT_ACTION, BROADCAST_INTENT_ACTION, SERVICE_ACTION, INTENT_CATEGORY, FEATURE; } SdkConstantType value(); diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 1115f92..909620d 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1383,13 +1383,14 @@ public final class ActivityThread { public final void scheduleRelaunchActivity(IBinder token, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, - int configChanges, boolean notResumed) { + int configChanges, boolean notResumed, Configuration config) { ActivityRecord r = new ActivityRecord(); r.token = token; r.pendingResults = pendingResults; r.pendingIntents = pendingNewIntents; r.startsNotResumed = notResumed; + r.createdConfig = config; synchronized (mRelaunchingActivities) { mRelaunchingActivities.add(r); @@ -2511,7 +2512,7 @@ public final class ActivityThread { Activity a = performLaunchActivity(r, customIntent); if (a != null) { - r.createdConfig = new Configuration(a.getResources().getConfiguration()); + r.createdConfig = new Configuration(mConfiguration); handleResumeActivity(r.token, false, r.isForward); if (!r.activity.mFinished && r.startsNotResumed) { @@ -3563,6 +3564,16 @@ public final class ActivityThread { } } + if (tmp.createdConfig != null) { + // If the activity manager is passing us its current config, + // assume that is really what we want regardless of what we + // may have pending. + if (mConfiguration == null + || mConfiguration.diff(tmp.createdConfig) != 0) { + changedConfig = tmp.createdConfig; + } + } + if (DEBUG_CONFIGURATION) Log.v(TAG, "Relaunching activity " + tmp.token + ": changedConfig=" + changedConfig); diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index a772a8f..7cba13f 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -140,7 +140,11 @@ public abstract class ApplicationThreadNative extends Binder List<Intent> pi = data.createTypedArrayList(Intent.CREATOR); int configChanges = data.readInt(); boolean notResumed = data.readInt() != 0; - scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed); + Configuration config = null; + if (data.readInt() != 0) { + config = Configuration.CREATOR.createFromParcel(data); + } + scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config); return true; } @@ -491,7 +495,8 @@ class ApplicationThreadProxy implements IApplicationThread { public final void scheduleRelaunchActivity(IBinder token, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, - int configChanges, boolean notResumed) throws RemoteException { + int configChanges, boolean notResumed, Configuration config) + throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); data.writeStrongBinder(token); @@ -499,6 +504,12 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeTypedList(pendingNewIntents); data.writeInt(configChanges); data.writeInt(notResumed ? 1 : 0); + if (config != null) { + data.writeInt(1); + config.writeToParcel(data, 0); + } else { + data.writeInt(0); + } mRemote.transact(SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); data.recycle(); diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java index 89a52fd..ed810d3 100644 --- a/core/java/android/app/IApplicationThread.java +++ b/core/java/android/app/IApplicationThread.java @@ -56,7 +56,7 @@ public interface IApplicationThread extends IInterface { throws RemoteException; void scheduleRelaunchActivity(IBinder token, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, int configChanges, - boolean notResumed) throws RemoteException; + boolean notResumed, Configuration config) throws RemoteException; void scheduleNewIntent(List<Intent> intent, IBinder token) throws RemoteException; void scheduleDestroyActivity(IBinder token, boolean finished, int configChanges) throws RemoteException; diff --git a/core/java/android/bluetooth/package.html b/core/java/android/bluetooth/package.html index 4f0755e..5ff240c 100644 --- a/core/java/android/bluetooth/package.html +++ b/core/java/android/bluetooth/package.html @@ -12,96 +12,16 @@ devices, connecting with devices, and managing data transfer between devices. <li>Transfer data to and from other devices</li> </ul> -<p class="note"><strong>Note:</strong> +<p> To perform Bluetooth communication using these APIs, an application must declare the {@link android.Manifest.permission#BLUETOOTH} permission. Some -additional functionality, such as requesting device discovery and -pairing also requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN} +additional functionality, such as requesting device discovery, +also requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission. </p> -<h3>Overview</h3> - -<p>Here's a basic introduction to the Bluetooth classes:</p> -<dl> - <dt>{@link android.bluetooth.BluetoothAdapter}</dt> - <dd>This represents the local Bluetooth adapter, which is essentially the - entry-point to performing any interaction with Bluetooth. With it, you can - discover other Bluetooth devices, query a list of bonded (paired) devices, - initialize a {@link android.bluetooth.BluetoothDevice} using a known MAC - address, and create a {@link android.bluetooth.BluetoothServerSocket} to - listen for communications from other devices.</dd> - - <dt>{@link android.bluetooth.BluetoothDevice}</dt> - <dd>This represents a remote Bluetooth device. Use this to request a - connection with a remote device through a - {@link android.bluetooth.BluetoothSocket} - or query information about the device such as its name, address, class, and - bonding state.</dd> - - <dt>{@link android.bluetooth.BluetoothSocket}</dt> - <dd>This represents the interface for a Bluetooth socket - (similar to a TCP client-side {@link java.net.Socket}). This is the - connection point that allows an app to transfer data with another Bluetooth - device via {@link java.io.InputStream} and {@link java.io.OutputStream}.</dd> - <dt>{@link android.bluetooth.BluetoothServerSocket}</dt> - - <dd>This represents an open server socket that listens for incoming requests - (similar to a TCP server-side {@link java.net.ServerSocket}). - When attempting to connect two Android devices, one device will need to open - a server socket with this class. When a connection is accepted, a new - {@link android.bluetooth.BluetoothSocket} will be returned, - which can be used to manage the connection and transfer data.</dd> - - <dt>{@link android.bluetooth.BluetoothClass}</dt> - <dd>This represents the Bluetooth class for a device which describes general - characteristics and capabilities of a device. This class and its subclasses - don't provide any actual functionality. The sub-classes are entirely composed - of constants for the device and service class definitions.</dd> -</dl> - - -<h3>Example Procedure</h3> - -<p>For example, here's an pseudo-code procedure for discovering and -connecting a remote device, and transfering data:</p> - -<ol> - <li>Register a {@link android.content.BroadcastReceiver} that accepts the - {@link android.bluetooth.BluetoothDevice#ACTION_FOUND} Intent.</li> - <li>Call {@link android.bluetooth.BluetoothAdapter#getDefaultAdapter} to - retrieve the Android system's local - {@link android.bluetooth.BluetoothAdapter}.</li> - <li>Call {@link android.bluetooth.BluetoothAdapter#startDiscovery() - BluetoothAdapter.startDiscovery()} to scan for local devices. This is where - the BroadcastReceiver comes in; Android now scans for devices and will - broadcast the {@link android.bluetooth.BluetoothDevice#ACTION_FOUND} Intent - for each remote device discovered. The - {@link android.content.BroadcastReceiver} - you created will receive each Intent.</li> - <li>The {@link android.bluetooth.BluetoothDevice#ACTION_FOUND} Intent - includes the {@link android.bluetooth.BluetoothDevice#EXTRA_DEVICE} - Parcelable extra, which is a {@link android.bluetooth.BluetoothDevice} - object. Extract this from the Intent and call - {@link android.bluetooth.BluetoothDevice#createRfcommSocketToServiceRecord(java.util.UUID) - BluetoothDevice.createRfcommSocketToServiceRecord()} - to open a {@link android.bluetooth.BluetoothSocket} with a chosen - remote device.</li> - <li>Call {@link android.bluetooth.BluetoothSocket#connect() - BluetoothSocket.connect()} to connect with the remote device.</li> - <li>When successfully connected, call - {@link android.bluetooth.BluetoothSocket#getInputStream() - BluetoothSocket.getInputStream()} and/or - {@link android.bluetooth.BluetoothSocket#getOutputStream() - BluetoothSocket.getOutputStream()} to retreive an - {@link java.io.InputStream} and {@link java.io.OutputStream}, respectively, - which are hooked into the socket.</li> - <li>Use {@link java.io.InputStream#read(byte[]) InputStream.read()} and - {@link java.io.OutputStream#write(byte[]) OutputStream.write()} to transfer - data.</li> -</ol> - - +<p>For a detailed guide to using the Bluetooth APIs, see the <a +href="{@docRoot}guide/topics/wireless/bluetooth.html">Bluetooth Dev Guide topic</a>.</p> <p class="note"><strong>Note:</strong> Not all Android devices are guaranteed to have Bluetooth functionality.</p> diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 03d2a6d..53a966d 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -16,6 +16,8 @@ package android.content.pm; +import android.annotation.SdkConstant; +import android.annotation.SdkConstant.SdkConstantType; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -518,30 +520,35 @@ public abstract class PackageManager { * {@link #hasSystemFeature}: The device has a camera facing away * from the screen. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_CAMERA = "android.hardware.camera"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device's camera supports auto-focus. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device's camera supports flash. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device includes a light sensor. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device includes a proximity sensor. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; /** @@ -549,30 +556,35 @@ public abstract class PackageManager { * {@link #hasSystemFeature}: The device has a telephony radio with data * communication support. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device has a CDMA telephony stack. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device has a GSM telephony stack. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device's touch screen supports multitouch. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device supports live wallpapers. */ + @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; /** diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index 0d0d245..b28cf43 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -21,14 +21,15 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothUuid; -import android.os.ParcelUuid; import android.content.Context; import android.content.Intent; import android.os.Handler; import android.os.Message; +import android.os.ParcelUuid; import android.util.Log; import java.util.HashMap; +import java.util.Set; /** * TODO: Move this to @@ -553,7 +554,7 @@ class BluetoothEventLoop { if (mBluetoothService.isEnabled() && (BluetoothUuid.isAudioSource(uuid) || BluetoothUuid.isAvrcpTarget(uuid) || BluetoothUuid.isAdvAudioDist(uuid)) && - (a2dp.getNonDisconnectedSinks().size() == 0)) { + !isOtherSinkInNonDisconnectingState(address)) { BluetoothDevice device = mAdapter.getRemoteDevice(address); authorized = a2dp.getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF; if (authorized) { @@ -568,6 +569,16 @@ class BluetoothEventLoop { return authorized; } + boolean isOtherSinkInNonDisconnectingState(String address) { + BluetoothA2dp a2dp = new BluetoothA2dp(mContext); + Set<BluetoothDevice> devices = a2dp.getNonDisconnectedSinks(); + if (devices.size() == 0) return false; + for(BluetoothDevice dev: devices) { + if (!dev.getAddress().equals(address)) return true; + } + return false; + } + private void onAgentCancel() { Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_CANCEL); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index bcdefb3..cdaba8a 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -4531,6 +4531,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Now use the delta to determine the actual amount of text // we need. partialEndOffset += delta; + if (partialStartOffset > N) { + partialStartOffset = N; + } else if (partialStartOffset < 0) { + partialStartOffset = 0; + } if (partialEndOffset > N) { partialEndOffset = N; } else if (partialEndOffset < 0) { diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 0d03ff2..3c35fc7 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -403,7 +403,13 @@ android:label="@string/permlab_recordAudio" android:description="@string/permdesc_recordAudio" /> - <!-- Required to be able to access the camera device. --> + <!-- Required to be able to access the camera device. + <p>This will automatically enforce the <a + href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code + <uses-feature>}</a> manifest element for <em>all</em> camera features. + If you do not require all camera features or can properly operate if a camera + is not available, then you must modify your manifest as appropriate in order to + install on devices that don't support all camera features.</p> --> <permission android:name="android.permission.CAMERA" android:permissionGroup="android.permission-group.HARDWARE_CONTROLS" android:protectionLevel="dangerous" |