diff options
41 files changed, 2304 insertions, 875 deletions
diff --git a/api/current.xml b/api/current.xml index 5f732e1..968b8ed 100644 --- a/api/current.xml +++ b/api/current.xml @@ -257571,6 +257571,21 @@ <parameter name="started" type="boolean"> </parameter> </method> +<method name="setDisplayedChild" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="viewId" type="int"> +</parameter> +<parameter name="childIndex" type="int"> +</parameter> +</method> <method name="setDouble" return="void" abstract="false" @@ -265605,7 +265620,7 @@ deprecated="not deprecated" visibility="public" > -<parameter name="arg0" type="T"> +<parameter name="t" type="T"> </parameter> </method> </interface> diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index f74e3c8..9e6bcc8 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -116,9 +116,7 @@ static void dumpstate() { #ifdef FWDUMP_bcm4329 run_command("DUMP WIFI STATUS", 20, - "su", "root", "dhdutil", "-i", "eth0", "dump", NULL); - run_command("DUMP WIFI FIRMWARE LOG", 60, - "su", "root", "dhdutil", "-i", "eth0", "upload", "/data/local/tmp/wlan_crash.dump", NULL); + "su", "root", "dhdutil", "-i", "wlan0", "dump", NULL); run_command("DUMP WIFI INTERNAL COUNTERS", 20, "su", "root", "wlutil", "counters", NULL); #endif diff --git a/core/java/android/net/LinkAddress.java b/core/java/android/net/LinkAddress.java index 3f03a2a..9c36b12 100644 --- a/core/java/android/net/LinkAddress.java +++ b/core/java/android/net/LinkAddress.java @@ -19,6 +19,7 @@ package android.net; import android.os.Parcel; import android.os.Parcelable; +import java.net.Inet4Address; import java.net.InetAddress; import java.net.InterfaceAddress; import java.net.UnknownHostException; @@ -38,12 +39,13 @@ public class LinkAddress implements Parcelable { */ private final int prefixLength; - public LinkAddress(InetAddress address, InetAddress mask) { - this.address = address; - this.prefixLength = computeprefixLength(mask); - } - public LinkAddress(InetAddress address, int prefixLength) { + if (address == null || prefixLength < 0 || + ((address instanceof Inet4Address) && prefixLength > 32) || + (prefixLength > 128)) { + throw new IllegalArgumentException("Bad LinkAddress params " + address + + prefixLength); + } this.address = address; this.prefixLength = prefixLength; } @@ -53,18 +55,6 @@ public class LinkAddress implements Parcelable { this.prefixLength = interfaceAddress.getNetworkPrefixLength(); } - private static int computeprefixLength(InetAddress mask) { - int count = 0; - for (byte b : mask.getAddress()) { - for (int i = 0; i < 8; ++i) { - if ((b & (1 << i)) != 0) { - ++count; - } - } - } - return count; - } - @Override public String toString() { return (address == null ? "" : (address.getHostAddress() + "/" + prefixLength)); diff --git a/core/java/android/provider/Calendar.java b/core/java/android/provider/Calendar.java index c007605..de71763 100644 --- a/core/java/android/provider/Calendar.java +++ b/core/java/android/provider/Calendar.java @@ -59,6 +59,10 @@ public final class Calendar { public static final String EVENT_BEGIN_TIME = "beginTime"; public static final String EVENT_END_TIME = "endTime"; + /** + * This must not be changed or horrible, unspeakable things could happen. + * For instance, the Calendar app might break. Also, the db might not work. + */ public static final String AUTHORITY = "com.android.calendar"; /** diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 8f922e2..b05b078 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -3843,60 +3843,6 @@ public final class ContactsContract { * @hide */ public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; - - /** - * The ID of the data row that was matched by the filter. - * - * @hide - * @deprecated - */ - @Deprecated - public static final String SNIPPET_DATA_ID = "snippet_data_id"; - - /** - * The type of data that was matched by the filter. - * - * @hide - * @deprecated - */ - @Deprecated - public static final String SNIPPET_MIMETYPE = "snippet_mimetype"; - - /** - * The {@link Data#DATA1} field of the data row that was matched by the filter. - * - * @hide - * @deprecated - */ - @Deprecated - public static final String SNIPPET_DATA1 = "snippet_data1"; - - /** - * The {@link Data#DATA2} field of the data row that was matched by the filter. - * - * @hide - * @deprecated - */ - @Deprecated - public static final String SNIPPET_DATA2 = "snippet_data2"; - - /** - * The {@link Data#DATA3} field of the data row that was matched by the filter. - * - * @hide - * @deprecated - */ - @Deprecated - public static final String SNIPPET_DATA3 = "snippet_data3"; - - /** - * The {@link Data#DATA4} field of the data row that was matched by the filter. - * - * @hide - * @deprecated - */ - @Deprecated - public static final String SNIPPET_DATA4 = "snippet_data4"; } /** diff --git a/core/java/android/server/BluetoothInputProfileHandler.java b/core/java/android/server/BluetoothInputProfileHandler.java new file mode 100644 index 0000000..7ffa5ae --- /dev/null +++ b/core/java/android/server/BluetoothInputProfileHandler.java @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2011 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.server; + +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothDeviceProfileState; +import android.bluetooth.BluetoothInputDevice; +import android.bluetooth.BluetoothProfileState; +import android.content.Context; +import android.content.Intent; +import android.os.Message; +import android.provider.Settings; +import android.util.Log; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * This handles all the operations on the HID profile. + * All functions are called by BluetoothService, as Bluetooth Service + * is the Service handler for the HID profile. + */ +final class BluetoothInputProfileHandler { + private static final String TAG = "BluetoothInputProfileHandler"; + private static final boolean DBG = true; + + public static BluetoothInputProfileHandler sInstance; + private Context mContext; + private BluetoothService mBluetoothService; + private final HashMap<BluetoothDevice, Integer> mInputDevices; + private final BluetoothProfileState mHidProfileState; + + private BluetoothInputProfileHandler(Context context, BluetoothService service) { + mContext = context; + mBluetoothService = service; + mInputDevices = new HashMap<BluetoothDevice, Integer>(); + mHidProfileState = new BluetoothProfileState(mContext, BluetoothProfileState.HID); + mHidProfileState.start(); + } + + static synchronized BluetoothInputProfileHandler getInstance(Context context, + BluetoothService service) { + if (sInstance == null) sInstance = new BluetoothInputProfileHandler(context, service); + return sInstance; + } + + synchronized boolean connectInputDevice(BluetoothDevice device, + BluetoothDeviceProfileState state) { + String objectPath = mBluetoothService.getObjectPathFromAddress(device.getAddress()); + if (objectPath == null || + getInputDeviceState(device) != BluetoothInputDevice.STATE_DISCONNECTED || + getInputDevicePriority(device) == BluetoothInputDevice.PRIORITY_OFF) { + return false; + } + if (state != null) { + Message msg = new Message(); + msg.arg1 = BluetoothDeviceProfileState.CONNECT_HID_OUTGOING; + msg.obj = state; + mHidProfileState.sendMessage(msg); + return true; + } + return false; + } + + synchronized boolean connectInputDeviceInternal(BluetoothDevice device) { + String objectPath = mBluetoothService.getObjectPathFromAddress(device.getAddress()); + handleInputDeviceStateChange(device, BluetoothInputDevice.STATE_CONNECTING); + if (!mBluetoothService.connectInputDeviceNative(objectPath)) { + handleInputDeviceStateChange(device, BluetoothInputDevice.STATE_DISCONNECTED); + return false; + } + return true; + } + + synchronized boolean disconnectInputDevice(BluetoothDevice device, + BluetoothDeviceProfileState state) { + String objectPath = mBluetoothService.getObjectPathFromAddress(device.getAddress()); + if (objectPath == null || + getInputDeviceState(device) == BluetoothInputDevice.STATE_DISCONNECTED) { + return false; + } + if (state != null) { + Message msg = new Message(); + msg.arg1 = BluetoothDeviceProfileState.DISCONNECT_HID_OUTGOING; + msg.obj = state; + mHidProfileState.sendMessage(msg); + return true; + } + return false; + } + + synchronized boolean disconnectInputDeviceInternal(BluetoothDevice device) { + String objectPath = mBluetoothService.getObjectPathFromAddress(device.getAddress()); + handleInputDeviceStateChange(device, BluetoothInputDevice.STATE_DISCONNECTING); + if (!mBluetoothService.disconnectInputDeviceNative(objectPath)) { + handleInputDeviceStateChange(device, BluetoothInputDevice.STATE_CONNECTED); + return false; + } + return true; + } + + synchronized int getInputDeviceState(BluetoothDevice device) { + if (mInputDevices.get(device) == null) { + return BluetoothInputDevice.STATE_DISCONNECTED; + } + return mInputDevices.get(device); + } + + synchronized List<BluetoothDevice> getConnectedInputDevices() { + List<BluetoothDevice> devices = lookupInputDevicesMatchingStates( + new int[] {BluetoothInputDevice.STATE_CONNECTED}); + return devices; + } + + synchronized int getInputDevicePriority(BluetoothDevice device) { + return Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.getBluetoothInputDevicePriorityKey(device.getAddress()), + BluetoothInputDevice.PRIORITY_UNDEFINED); + } + + synchronized boolean setInputDevicePriority(BluetoothDevice device, int priority) { + if (!BluetoothAdapter.checkBluetoothAddress(device.getAddress())) { + return false; + } + return Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.getBluetoothInputDevicePriorityKey(device.getAddress()), + priority); + } + + synchronized List<BluetoothDevice> lookupInputDevicesMatchingStates(int[] states) { + List<BluetoothDevice> inputDevices = new ArrayList<BluetoothDevice>(); + + for (BluetoothDevice device: mInputDevices.keySet()) { + int inputDeviceState = getInputDeviceState(device); + for (int state : states) { + if (state == inputDeviceState) { + inputDevices.add(device); + break; + } + } + } + return inputDevices; + } + + private synchronized void handleInputDeviceStateChange(BluetoothDevice device, int state) { + int prevState; + if (mInputDevices.get(device) == null) { + prevState = BluetoothInputDevice.STATE_DISCONNECTED; + } else { + prevState = mInputDevices.get(device); + } + if (prevState == state) return; + + mInputDevices.put(device, state); + + if (getInputDevicePriority(device) > + BluetoothInputDevice.PRIORITY_OFF && + state == BluetoothInputDevice.STATE_CONNECTING || + state == BluetoothInputDevice.STATE_CONNECTED) { + // We have connected or attempting to connect. + // Bump priority + setInputDevicePriority(device, BluetoothInputDevice.PRIORITY_AUTO_CONNECT); + } + + Intent intent = new Intent(BluetoothInputDevice.ACTION_INPUT_DEVICE_STATE_CHANGED); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); + intent.putExtra(BluetoothInputDevice.EXTRA_PREVIOUS_INPUT_DEVICE_STATE, prevState); + intent.putExtra(BluetoothInputDevice.EXTRA_INPUT_DEVICE_STATE, state); + mContext.sendBroadcast(intent, BluetoothService.BLUETOOTH_PERM); + + debugLog("InputDevice state : device: " + device + " State:" + prevState + "->" + state); + mBluetoothService.sendConnectionStateChange(device, state, prevState); + } + + synchronized void handleInputDevicePropertyChange(String address, boolean connected) { + int state = connected ? BluetoothInputDevice.STATE_CONNECTED : + BluetoothInputDevice.STATE_DISCONNECTED; + BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); + BluetoothDevice device = adapter.getRemoteDevice(address); + handleInputDeviceStateChange(device, state); + } + + synchronized void setInitialInputDevicePriority(BluetoothDevice device, int state) { + switch (state) { + case BluetoothDevice.BOND_BONDED: + if (getInputDevicePriority(device) == BluetoothInputDevice.PRIORITY_UNDEFINED) { + setInputDevicePriority(device, BluetoothInputDevice.PRIORITY_ON); + } + break; + case BluetoothDevice.BOND_NONE: + setInputDevicePriority(device, BluetoothInputDevice.PRIORITY_UNDEFINED); + break; + } + } + + private static void debugLog(String msg) { + if (DBG) Log.d(TAG, msg); + } + + private static void errorLog(String msg) { + Log.e(TAG, msg); + } +} diff --git a/core/java/android/server/BluetoothPanProfileHandler.java b/core/java/android/server/BluetoothPanProfileHandler.java new file mode 100644 index 0000000..fb96439 --- /dev/null +++ b/core/java/android/server/BluetoothPanProfileHandler.java @@ -0,0 +1,395 @@ +/* + * Copyright (C) 2011 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.server; + +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothPan; +import android.bluetooth.BluetoothTetheringDataTracker; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.res.Resources.NotFoundException; +import android.net.ConnectivityManager; +import android.net.InterfaceConfiguration; +import android.net.LinkAddress; +import android.os.IBinder; +import android.os.INetworkManagementService; +import android.os.ServiceManager; +import android.util.Log; + +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * This handles the PAN profile. All calls into this are made + * from Bluetooth Service. + */ +final class BluetoothPanProfileHandler { + private static final String TAG = "BluetoothPanProfileHandler"; + private static final boolean DBG = true; + + private ArrayList<String> mBluetoothIfaceAddresses; + private int mMaxPanDevices; + + private static final String BLUETOOTH_IFACE_ADDR_START= "192.168.44.1"; + private static final int BLUETOOTH_MAX_PAN_CONNECTIONS = 5; + private static final int BLUETOOTH_PREFIX_LENGTH = 24; + public static BluetoothPanProfileHandler sInstance; + private final HashMap<BluetoothDevice, BluetoothPanDevice> mPanDevices; + private boolean mTetheringOn; + private Context mContext; + private BluetoothService mBluetoothService; + + private BluetoothPanProfileHandler(Context context, BluetoothService service) { + mContext = context; + mPanDevices = new HashMap<BluetoothDevice, BluetoothPanDevice>(); + mBluetoothService = service; + mTetheringOn = false; + mBluetoothIfaceAddresses = new ArrayList<String>(); + try { + mMaxPanDevices = context.getResources().getInteger( + com.android.internal.R.integer.config_max_pan_devices); + } catch (NotFoundException e) { + mMaxPanDevices = BLUETOOTH_MAX_PAN_CONNECTIONS; + } + } + + static synchronized BluetoothPanProfileHandler getInstance(Context context, + BluetoothService service) { + if (sInstance == null) sInstance = new BluetoothPanProfileHandler(context, service); + return sInstance; + } + + synchronized boolean isTetheringOn() { + return mTetheringOn; + } + + synchronized boolean allowIncomingTethering() { + if (isTetheringOn() && getConnectedPanDevices().size() < mMaxPanDevices) + return true; + return false; + } + + private BroadcastReceiver mTetheringReceiver = null; + + synchronized void setBluetoothTethering(boolean value) { + if (!value) { + disconnectPanServerDevices(); + } + + if (mBluetoothService.getBluetoothState() != BluetoothAdapter.STATE_ON && value) { + IntentFilter filter = new IntentFilter(); + filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); + mTetheringReceiver = new BroadcastReceiver() { + @Override + public synchronized void onReceive(Context context, Intent intent) { + if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_OFF) + == BluetoothAdapter.STATE_ON) { + mTetheringOn = true; + mContext.unregisterReceiver(mTetheringReceiver); + } + } + }; + mContext.registerReceiver(mTetheringReceiver, filter); + } else { + mTetheringOn = value; + } + } + + synchronized int getPanDeviceState(BluetoothDevice device) { + BluetoothPanDevice panDevice = mPanDevices.get(device); + if (panDevice == null) { + return BluetoothPan.STATE_DISCONNECTED; + } + return panDevice.mState; + } + + synchronized boolean connectPanDevice(BluetoothDevice device) { + String objectPath = mBluetoothService.getObjectPathFromAddress(device.getAddress()); + if (DBG) Log.d(TAG, "connect PAN(" + objectPath + ")"); + if (getPanDeviceState(device) != BluetoothPan.STATE_DISCONNECTED) { + errorLog(device + " already connected to PAN"); + } + + int connectedCount = 0; + for (BluetoothDevice panDevice: mPanDevices.keySet()) { + if (getPanDeviceState(panDevice) == BluetoothPan.STATE_CONNECTED) { + connectedCount ++; + } + } + if (connectedCount > 8) { + debugLog(device + " could not connect to PAN because 8 other devices are" + + "already connected"); + return false; + } + + handlePanDeviceStateChange(device, BluetoothPan.STATE_CONNECTING, + BluetoothPan.LOCAL_PANU_ROLE); + if (mBluetoothService.connectPanDeviceNative(objectPath, "nap")) { + debugLog("connecting to PAN"); + return true; + } else { + handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTED, + BluetoothPan.LOCAL_PANU_ROLE); + errorLog("could not connect to PAN"); + return false; + } + } + + private synchronized boolean disconnectPanServerDevices() { + debugLog("disconnect all PAN devices"); + + for (BluetoothDevice device: mPanDevices.keySet()) { + BluetoothPanDevice panDevice = mPanDevices.get(device); + int state = panDevice.mState; + if (state == BluetoothPan.STATE_CONNECTED && + panDevice.mLocalRole == BluetoothPan.LOCAL_NAP_ROLE) { + String objectPath = mBluetoothService.getObjectPathFromAddress(device.getAddress()); + + handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTING, + panDevice.mLocalRole); + + if (!mBluetoothService.disconnectPanServerDeviceNative(objectPath, + device.getAddress(), + panDevice.mIfaceAddr)) { + errorLog("could not disconnect Pan Server Device "+device.getAddress()); + + // Restore prev state + handlePanDeviceStateChange(device, state, + panDevice.mLocalRole); + + return false; + } + } + } + return true; + } + + synchronized List<BluetoothDevice> getConnectedPanDevices() { + List<BluetoothDevice> devices = new ArrayList<BluetoothDevice>(); + + for (BluetoothDevice device: mPanDevices.keySet()) { + if (getPanDeviceState(device) == BluetoothPan.STATE_CONNECTED) { + devices.add(device); + } + } + return devices; + } + + synchronized boolean disconnectPanDevice(BluetoothDevice device) { + String objectPath = mBluetoothService.getObjectPathFromAddress(device.getAddress()); + debugLog("disconnect PAN(" + objectPath + ")"); + + int state = getPanDeviceState(device); + if (state != BluetoothPan.STATE_CONNECTED) { + debugLog(device + " already disconnected from PAN"); + return false; + } + + BluetoothPanDevice panDevice = mPanDevices.get(device); + + if (panDevice == null) { + errorLog("No record for this Pan device:" + device); + return false; + } + + handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTING, + panDevice.mLocalRole); + if (panDevice.mLocalRole == BluetoothPan.LOCAL_NAP_ROLE) { + if (!mBluetoothService.disconnectPanServerDeviceNative(objectPath, device.getAddress(), + panDevice.mIface)) { + // Restore prev state, this shouldn't happen + handlePanDeviceStateChange(device, state, panDevice.mLocalRole); + return false; + } + } else { + if (!mBluetoothService.disconnectPanDeviceNative(objectPath)) { + // Restore prev state, this shouldn't happen + handlePanDeviceStateChange(device, state, panDevice.mLocalRole); + return false; + } + } + return true; + } + + synchronized void handlePanDeviceStateChange(BluetoothDevice device, + String iface, int state, int role) { + int prevState; + String ifaceAddr = null; + BluetoothPanDevice panDevice = mPanDevices.get(device); + + if (panDevice == null) { + prevState = BluetoothPan.STATE_DISCONNECTED; + } else { + prevState = panDevice.mState; + ifaceAddr = panDevice.mIfaceAddr; + } + if (prevState == state) return; + + if (role == BluetoothPan.LOCAL_NAP_ROLE) { + if (state == BluetoothPan.STATE_CONNECTED) { + ifaceAddr = enableTethering(iface); + if (ifaceAddr == null) Log.e(TAG, "Error seting up tether interface"); + } else if (state == BluetoothPan.STATE_DISCONNECTED) { + if (ifaceAddr != null) { + mBluetoothIfaceAddresses.remove(ifaceAddr); + ifaceAddr = null; + } + } + } else { + // PANU Role = reverse Tether + if (state == BluetoothPan.STATE_CONNECTED) { + BluetoothTetheringDataTracker.getInstance().startReverseTether(iface, device); + } else if (state == BluetoothPan.STATE_DISCONNECTED && + (prevState == BluetoothPan.STATE_CONNECTED || + prevState == BluetoothPan.STATE_DISCONNECTING)) { + BluetoothTetheringDataTracker.getInstance().stopReverseTether(panDevice.mIface); + } + } + + if (panDevice == null) { + panDevice = new BluetoothPanDevice(state, ifaceAddr, iface, role); + mPanDevices.put(device, panDevice); + } else { + panDevice.mState = state; + panDevice.mIfaceAddr = ifaceAddr; + panDevice.mLocalRole = role; + } + + if (state == BluetoothPan.STATE_DISCONNECTED) { + mPanDevices.remove(device); + } + + Intent intent = new Intent(BluetoothPan.ACTION_PAN_STATE_CHANGED); + intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); + intent.putExtra(BluetoothPan.EXTRA_PREVIOUS_PAN_STATE, prevState); + intent.putExtra(BluetoothPan.EXTRA_PAN_STATE, state); + intent.putExtra(BluetoothPan.EXTRA_LOCAL_ROLE, role); + mContext.sendBroadcast(intent, BluetoothService.BLUETOOTH_PERM); + + debugLog("Pan Device state : device: " + device + " State:" + prevState + "->" + state); + mBluetoothService.sendConnectionStateChange(device, state, prevState); + } + + synchronized void handlePanDeviceStateChange(BluetoothDevice device, + int state, int role) { + handlePanDeviceStateChange(device, null, state, role); + } + + private class BluetoothPanDevice { + private int mState; + private String mIfaceAddr; + private String mIface; + private int mLocalRole; // Which local role is this PAN device bound to + + BluetoothPanDevice(int state, String ifaceAddr, String iface, int localRole) { + mState = state; + mIfaceAddr = ifaceAddr; + mIface = iface; + mLocalRole = localRole; + } + } + + private String createNewTetheringAddressLocked() { + if (getConnectedPanDevices().size() == mMaxPanDevices) { + debugLog ("Max PAN device connections reached"); + return null; + } + String address = BLUETOOTH_IFACE_ADDR_START; + while (true) { + if (mBluetoothIfaceAddresses.contains(address)) { + String[] addr = address.split("\\."); + Integer newIp = Integer.parseInt(addr[2]) + 1; + address = address.replace(addr[2], newIp.toString()); + } else { + break; + } + } + mBluetoothIfaceAddresses.add(address); + return address; + } + + // configured when we start tethering + private synchronized String enableTethering(String iface) { + debugLog("updateTetherState:" + iface); + + IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); + INetworkManagementService service = INetworkManagementService.Stub.asInterface(b); + ConnectivityManager cm = + (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); + String[] bluetoothRegexs = cm.getTetherableBluetoothRegexs(); + + // bring toggle the interfaces + String[] currentIfaces = new String[0]; + try { + currentIfaces = service.listInterfaces(); + } catch (Exception e) { + Log.e(TAG, "Error listing Interfaces :" + e); + return null; + } + + boolean found = false; + for (String currIface: currentIfaces) { + if (currIface.equals(iface)) { + found = true; + break; + } + } + + if (!found) return null; + + String address = createNewTetheringAddressLocked(); + if (address == null) return null; + + InterfaceConfiguration ifcg = null; + try { + ifcg = service.getInterfaceConfig(iface); + if (ifcg != null) { + InetAddress addr = null; + if (ifcg.addr == null || (addr = ifcg.addr.getAddress()) == null || + addr.equals(InetAddress.getByName("0.0.0.0")) || + addr.equals(InetAddress.getByName("::0"))) { + addr = InetAddress.getByName(address); + } + ifcg.interfaceFlags = ifcg.interfaceFlags.replace("down", "up"); + ifcg.addr = new LinkAddress(addr, BLUETOOTH_PREFIX_LENGTH); + ifcg.interfaceFlags = ifcg.interfaceFlags.replace("running", ""); + ifcg.interfaceFlags = ifcg.interfaceFlags.replace(" "," "); + service.setInterfaceConfig(iface, ifcg); + if (cm.tether(iface) != ConnectivityManager.TETHER_ERROR_NO_ERROR) { + Log.e(TAG, "Error tethering "+iface); + } + } + } catch (Exception e) { + Log.e(TAG, "Error configuring interface " + iface + ", :" + e); + return null; + } + return address; + } + + private static void debugLog(String msg) { + if (DBG) Log.d(TAG, msg); + } + + private static void errorLog(String msg) { + Log.e(TAG, msg); + } +} diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index df5097e..a295de5 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -24,17 +24,17 @@ package android.server; +import com.android.internal.app.IBatteryStats; + import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDeviceProfileState; import android.bluetooth.BluetoothHeadset; -import android.bluetooth.BluetoothInputDevice; import android.bluetooth.BluetoothPan; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothProfileState; import android.bluetooth.BluetoothSocket; -import android.bluetooth.BluetoothTetheringDataTracker; import android.bluetooth.BluetoothUuid; import android.bluetooth.IBluetooth; import android.bluetooth.IBluetoothCallback; @@ -44,14 +44,9 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; -import android.content.res.Resources.NotFoundException; -import android.net.ConnectivityManager; -import android.net.InterfaceConfiguration; -import android.net.LinkAddress; import android.os.Binder; import android.os.Handler; import android.os.IBinder; -import android.os.INetworkManagementService; import android.os.Message; import android.os.ParcelUuid; import android.os.RemoteException; @@ -60,8 +55,6 @@ import android.provider.Settings; import android.util.Log; import android.util.Pair; -import com.android.internal.app.IBatteryStats; - import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -76,7 +69,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; -import java.net.InetAddress; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -96,7 +88,6 @@ public class BluetoothService extends IBluetooth.Stub { private int mBluetoothState; private boolean mRestart = false; // need to call enable() after disable() private boolean mIsDiscovering; - private boolean mTetheringOn; private int[] mAdapterSdpHandles; private ParcelUuid[] mAdapterUuids; @@ -106,7 +97,7 @@ public class BluetoothService extends IBluetooth.Stub { private final Context mContext; private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN; - private static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH; + static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH; private static final String DOCK_ADDRESS_PATH = "/sys/class/switch/dock/bt_addr"; private static final String DOCK_PIN_PATH = "/sys/class/switch/dock/bt_pin"; @@ -125,13 +116,6 @@ public class BluetoothService extends IBluetooth.Stub { private static final long INIT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 3000; private static final long MAX_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 12000; - private ArrayList<String> mBluetoothIfaceAddresses; - private int mMaxPanDevices; - - private static final String BLUETOOTH_IFACE_ADDR_START= "192.168.44.1"; - private static final int BLUETOOTH_MAX_PAN_CONNECTIONS = 5; - private static final String BLUETOOTH_NETMASK = "255.255.255.0"; - // The timeout used to sent the UUIDs Intent // This timeout should be greater than the page timeout private static final int UUID_INTENT_DELAY = 6000; @@ -155,11 +139,8 @@ public class BluetoothService extends IBluetooth.Stub { private final HashMap<String, BluetoothDeviceProfileState> mDeviceProfileState; private final BluetoothProfileState mA2dpProfileState; private final BluetoothProfileState mHfpProfileState; - private final BluetoothProfileState mHidProfileState; private BluetoothA2dpService mA2dpService; - private final HashMap<BluetoothDevice, Integer> mInputDevices; - private final HashMap<BluetoothDevice, Pair<Integer, String>> mPanDevices; private final HashMap<String, Pair<byte[], byte[]>> mDeviceOobData; private int mProfilesConnected = 0, mProfilesConnecting = 0, mProfilesDisconnecting = 0; @@ -167,9 +148,9 @@ public class BluetoothService extends IBluetooth.Stub { private static String mDockAddress; private String mDockPin; - private String mIface; - private int mAdapterConnectionState = BluetoothAdapter.STATE_DISCONNECTED; + private BluetoothPanProfileHandler mBluetoothPanProfileHandler; + private BluetoothInputProfileHandler mBluetoothInputProfileHandler; private static class RemoteService { public String address; @@ -218,7 +199,7 @@ public class BluetoothService extends IBluetooth.Stub { mBluetoothState = BluetoothAdapter.STATE_OFF; mIsDiscovering = false; - mTetheringOn = false; + mAdapterProperties = new HashMap<String, String>(); mDeviceProperties = new HashMap<String, Map<String,String>>(); @@ -230,27 +211,17 @@ public class BluetoothService extends IBluetooth.Stub { mDeviceProfileState = new HashMap<String, BluetoothDeviceProfileState>(); mA2dpProfileState = new BluetoothProfileState(mContext, BluetoothProfileState.A2DP); mHfpProfileState = new BluetoothProfileState(mContext, BluetoothProfileState.HFP); - mHidProfileState = new BluetoothProfileState(mContext, BluetoothProfileState.HID); - - mBluetoothIfaceAddresses = new ArrayList<String>(); - try { - mMaxPanDevices = context.getResources().getInteger( - com.android.internal.R.integer.config_max_pan_devices); - } catch (NotFoundException e) { - mMaxPanDevices = BLUETOOTH_MAX_PAN_CONNECTIONS; - } mHfpProfileState.start(); mA2dpProfileState.start(); - mHidProfileState.start(); IntentFilter filter = new IntentFilter(); registerForAirplaneMode(filter); filter.addAction(Intent.ACTION_DOCK_EVENT); mContext.registerReceiver(mReceiver, filter); - mInputDevices = new HashMap<BluetoothDevice, Integer>(); - mPanDevices = new HashMap<BluetoothDevice, Pair<Integer, String>>(); + mBluetoothInputProfileHandler = BluetoothInputProfileHandler.getInstance(mContext, this); + mBluetoothPanProfileHandler = BluetoothPanProfileHandler.getInstance(mContext, this); } public static synchronized String readDockBluetoothAddress() { @@ -590,21 +561,16 @@ public class BluetoothService extends IBluetooth.Stub { persistBluetoothOnSetting(true); } - updateSdpRecords(); - mIsDiscovering = false; mBondState.readAutoPairingData(); mBondState.loadBondState(); initProfileState(); - // Log bluetooth on to battery stats. - long ident = Binder.clearCallingIdentity(); - try { - mBatteryStats.noteBluetoothOn(); - } catch (RemoteException e) { - } finally { - Binder.restoreCallingIdentity(ident); - } + // This should be the last step of the the enable thread. + // Because this adds SDP records which asynchronously + // broadcasts the Bluetooth On State in updateBluetoothState. + // So we want all internal state setup before this. + updateSdpRecords(); } else { setBluetoothState(BluetoothAdapter.STATE_OFF); } @@ -652,6 +618,11 @@ public class BluetoothService extends IBluetooth.Stub { } } + /** + * This function is called from Bluetooth Event Loop when onPropertyChanged + * for adapter comes in with UUID property. + * @param uuidsThe uuids of adapter as reported by Bluez. + */ synchronized void updateBluetoothState(String uuids) { if (mBluetoothState == BluetoothAdapter.STATE_TURNING_ON) { ParcelUuid[] adapterUuids = convertStringToParcelUuid(uuids); @@ -662,6 +633,15 @@ public class BluetoothService extends IBluetooth.Stub { String[] propVal = {"Pairable", getProperty("Pairable")}; mEventLoop.onPropertyChanged(propVal); + // Log bluetooth on to battery stats. + long ident = Binder.clearCallingIdentity(); + try { + mBatteryStats.noteBluetoothOn(); + } catch (RemoteException e) { + } finally { + Binder.restoreCallingIdentity(ident); + } + if (mIsAirplaneSensitive && isAirplaneModeOn() && !mIsAirplaneToggleable) { disable(false); } @@ -825,7 +805,8 @@ public class BluetoothService extends IBluetooth.Stub { // HID is handled by BluetoothService, other profiles // will be handled by their respective services. - setInitialInputDevicePriority(mAdapter.getRemoteDevice(address), state); + mBluetoothInputProfileHandler.setInitialInputDevicePriority( + mAdapter.getRemoteDevice(address), state); if (DBG) log(address + " bond state " + oldState + " -> " + state + " (" + reason + ")"); @@ -1472,425 +1453,6 @@ public class BluetoothService extends IBluetooth.Stub { return sp.contains(SHARED_PREFERENCE_DOCK_ADDRESS + address); } - public synchronized boolean isTetheringOn() { - return mTetheringOn; - } - - /*package*/ synchronized boolean allowIncomingTethering() { - if (isTetheringOn() && getConnectedPanDevices().size() < mMaxPanDevices) - return true; - return false; - } - - private BroadcastReceiver mTetheringReceiver = null; - - public synchronized void setBluetoothTethering(boolean value) { - if (!value) { - disconnectPan(); - } - - if (getBluetoothState() != BluetoothAdapter.STATE_ON && value) { - IntentFilter filter = new IntentFilter(); - filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); - mTetheringReceiver = new BroadcastReceiver() { - @Override - public synchronized void onReceive(Context context, Intent intent) { - if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_OFF) - == BluetoothAdapter.STATE_ON) { - mTetheringOn = true; - mContext.unregisterReceiver(mTetheringReceiver); - } - } - }; - mContext.registerReceiver(mTetheringReceiver, filter); - } else { - mTetheringOn = value; - } - } - - public synchronized int getPanDeviceState(BluetoothDevice device) { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - - Pair<Integer, String> panDevice = mPanDevices.get(device); - if (panDevice == null) { - return BluetoothPan.STATE_DISCONNECTED; - } - return panDevice.first; - } - - public synchronized boolean connectPanDevice(BluetoothDevice device) { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, - "Need BLUETOOTH_ADMIN permission"); - - String objectPath = getObjectPathFromAddress(device.getAddress()); - if (DBG) log("connect PAN(" + objectPath + ")"); - if (getPanDeviceState(device) != BluetoothPan.STATE_DISCONNECTED) { - log (device + " already connected to PAN"); - } - - int connectedCount = 0; - for (BluetoothDevice panDevice: mPanDevices.keySet()) { - if (getPanDeviceState(panDevice) == BluetoothPan.STATE_CONNECTED) { - connectedCount ++; - } - } - if (connectedCount > 8) { - log (device + " could not connect to PAN because 8 other devices are already connected"); - return false; - } - - handlePanDeviceStateChange(device, BluetoothPan.STATE_CONNECTING, - BluetoothPan.LOCAL_PANU_ROLE); - if (connectPanDeviceNative(objectPath, "nap")) { - log ("connecting to PAN"); - return true; - } else { - handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTED, - BluetoothPan.LOCAL_PANU_ROLE); - log ("could not connect to PAN"); - return false; - } - } - - private synchronized boolean disconnectPan() { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - if (DBG) log("disconnect all PAN devices"); - - for (BluetoothDevice device: mPanDevices.keySet()) { - if (getPanDeviceState(device) == BluetoothPan.STATE_CONNECTED) { - if (!disconnectPanDevice(device)) { - log ("could not disconnect Pan Device "+device.getAddress()); - return false; - } - } - } - return true; - } - - public synchronized List<BluetoothDevice> getConnectedPanDevices() { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - - List<BluetoothDevice> devices = new ArrayList<BluetoothDevice>(); - - for (BluetoothDevice device: mPanDevices.keySet()) { - if (getPanDeviceState(device) == BluetoothPan.STATE_CONNECTED) { - devices.add(device); - } - } - return devices; - } - - public synchronized boolean disconnectPanDevice(BluetoothDevice device) { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, - "Need BLUETOOTH_ADMIN permission"); - String objectPath = getObjectPathFromAddress(device.getAddress()); - if (DBG) log("disconnect PAN(" + objectPath + ")"); - if (getPanDeviceState(device) != BluetoothPan.STATE_CONNECTED) { - log (device + " already disconnected from PAN"); - } - handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTING, - BluetoothPan.LOCAL_PANU_ROLE); - return disconnectPanDeviceNative(objectPath); - } - - /*package*/ synchronized void handlePanDeviceStateChange(BluetoothDevice device, - String iface, - int state, - int role) { - int prevState; - String ifaceAddr = null; - - if (mPanDevices.get(device) == null) { - prevState = BluetoothPan.STATE_DISCONNECTED; - } else { - prevState = mPanDevices.get(device).first; - ifaceAddr = mPanDevices.get(device).second; - } - if (prevState == state) return; - - if (role == BluetoothPan.LOCAL_NAP_ROLE) { - if (state == BluetoothPan.STATE_CONNECTED) { - ifaceAddr = enableTethering(iface); - if (ifaceAddr == null) Log.e(TAG, "Error seting up tether interface"); - } else if (state == BluetoothPan.STATE_DISCONNECTED) { - if (ifaceAddr != null) { - mBluetoothIfaceAddresses.remove(ifaceAddr); - ifaceAddr = null; - } - } - } else { - // PANU Role = reverse Tether - if (state == BluetoothPan.STATE_CONNECTED) { - mIface = iface; - BluetoothTetheringDataTracker.getInstance().startReverseTether(iface, device); - } else if (state == BluetoothPan.STATE_DISCONNECTED && - (prevState == BluetoothPan.STATE_CONNECTED || - prevState == BluetoothPan.STATE_DISCONNECTING)) { - BluetoothTetheringDataTracker.getInstance().stopReverseTether(mIface); - } - } - - Pair<Integer, String> value = new Pair<Integer, String>(state, ifaceAddr); - mPanDevices.put(device, value); - - Intent intent = new Intent(BluetoothPan.ACTION_PAN_STATE_CHANGED); - intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); - intent.putExtra(BluetoothPan.EXTRA_PREVIOUS_PAN_STATE, prevState); - intent.putExtra(BluetoothPan.EXTRA_PAN_STATE, state); - intent.putExtra(BluetoothPan.EXTRA_LOCAL_ROLE, role); - mContext.sendBroadcast(intent, BLUETOOTH_PERM); - - if (DBG) log("Pan Device state : device: " + device + " State:" + prevState + "->" + state); - sendConnectionStateChange(device, state, prevState); - } - - /*package*/ synchronized void handlePanDeviceStateChange(BluetoothDevice device, - int state, int role) { - handlePanDeviceStateChange(device, null, state, role); - } - - private String createNewTetheringAddressLocked() { - if (getConnectedPanDevices().size() == mMaxPanDevices) { - log("Max PAN device connections reached"); - return null; - } - String address = BLUETOOTH_IFACE_ADDR_START; - while (true) { - if (mBluetoothIfaceAddresses.contains(address)) { - String[] addr = address.split("\\."); - Integer newIp = Integer.parseInt(addr[2]) + 1; - address = address.replace(addr[2], newIp.toString()); - } else { - break; - } - } - mBluetoothIfaceAddresses.add(address); - return address; - } - - // configured when we start tethering - private synchronized String enableTethering(String iface) { - log("updateTetherState:" + iface); - - IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); - INetworkManagementService service = INetworkManagementService.Stub.asInterface(b); - ConnectivityManager cm = - (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); - String[] bluetoothRegexs = cm.getTetherableBluetoothRegexs(); - - // bring toggle the interfaces - String[] currentIfaces = new String[0]; - try { - currentIfaces = service.listInterfaces(); - } catch (Exception e) { - Log.e(TAG, "Error listing Interfaces :" + e); - return null; - } - - boolean found = false; - for (String currIface: currentIfaces) { - if (currIface.equals(iface)) { - found = true; - break; - } - } - - if (!found) return null; - - String address = createNewTetheringAddressLocked(); - if (address == null) return null; - - InterfaceConfiguration ifcg = null; - try { - ifcg = service.getInterfaceConfig(iface); - if (ifcg != null) { - InetAddress mask = InetAddress.getByName(BLUETOOTH_NETMASK); - InetAddress addr = null; - if (ifcg.addr == null || (addr = ifcg.addr.getAddress()) == null || - addr.equals(InetAddress.getByName("0.0.0.0")) || - addr.equals(InetAddress.getByName("::0"))) { - addr = InetAddress.getByName(address); - } - ifcg.interfaceFlags = ifcg.interfaceFlags.replace("down", "up"); - ifcg.addr = new LinkAddress(addr, mask); - ifcg.interfaceFlags = ifcg.interfaceFlags.replace("running", ""); - ifcg.interfaceFlags = ifcg.interfaceFlags.replace(" "," "); - service.setInterfaceConfig(iface, ifcg); - if (cm.tether(iface) != ConnectivityManager.TETHER_ERROR_NO_ERROR) { - Log.e(TAG, "Error tethering "+iface); - } - } - } catch (Exception e) { - Log.e(TAG, "Error configuring interface " + iface + ", :" + e); - return null; - } - return address; - } - - public synchronized boolean connectInputDevice(BluetoothDevice device) { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, - "Need BLUETOOTH_ADMIN permission"); - - String objectPath = getObjectPathFromAddress(device.getAddress()); - if (objectPath == null || - getInputDeviceState(device) != BluetoothInputDevice.STATE_DISCONNECTED || - getInputDevicePriority(device) == BluetoothInputDevice.PRIORITY_OFF) { - return false; - } - BluetoothDeviceProfileState state = mDeviceProfileState.get(device.getAddress()); - if (state != null) { - Message msg = new Message(); - msg.arg1 = BluetoothDeviceProfileState.CONNECT_HID_OUTGOING; - msg.obj = state; - mHidProfileState.sendMessage(msg); - return true; - } - return false; - } - - public synchronized boolean connectInputDeviceInternal(BluetoothDevice device) { - String objectPath = getObjectPathFromAddress(device.getAddress()); - handleInputDeviceStateChange(device, BluetoothInputDevice.STATE_CONNECTING); - if (!connectInputDeviceNative(objectPath)) { - handleInputDeviceStateChange(device, BluetoothInputDevice.STATE_DISCONNECTED); - return false; - } - return true; - } - - public synchronized boolean disconnectInputDevice(BluetoothDevice device) { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, - "Need BLUETOOTH_ADMIN permission"); - - String objectPath = getObjectPathFromAddress(device.getAddress()); - if (objectPath == null || - getInputDeviceState(device) == BluetoothInputDevice.STATE_DISCONNECTED) { - return false; - } - BluetoothDeviceProfileState state = mDeviceProfileState.get(device.getAddress()); - if (state != null) { - Message msg = new Message(); - msg.arg1 = BluetoothDeviceProfileState.DISCONNECT_HID_OUTGOING; - msg.obj = state; - mHidProfileState.sendMessage(msg); - return true; - } - return false; - } - - public synchronized boolean disconnectInputDeviceInternal(BluetoothDevice device) { - String objectPath = getObjectPathFromAddress(device.getAddress()); - handleInputDeviceStateChange(device, BluetoothInputDevice.STATE_DISCONNECTING); - if (!disconnectInputDeviceNative(objectPath)) { - handleInputDeviceStateChange(device, BluetoothInputDevice.STATE_CONNECTED); - return false; - } - return true; - } - - public synchronized int getInputDeviceState(BluetoothDevice device) { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - - if (mInputDevices.get(device) == null) { - return BluetoothInputDevice.STATE_DISCONNECTED; - } - return mInputDevices.get(device); - } - - public synchronized List<BluetoothDevice> getConnectedInputDevices() { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - List<BluetoothDevice> devices = lookupInputDevicesMatchingStates( - new int[] {BluetoothInputDevice.STATE_CONNECTED}); - return devices; - } - - public synchronized int getInputDevicePriority(BluetoothDevice device) { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - return Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.getBluetoothInputDevicePriorityKey(device.getAddress()), - BluetoothInputDevice.PRIORITY_UNDEFINED); - } - - public synchronized boolean setInputDevicePriority(BluetoothDevice device, int priority) { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, - "Need BLUETOOTH_ADMIN permission"); - if (!BluetoothAdapter.checkBluetoothAddress(device.getAddress())) { - return false; - } - return Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.getBluetoothInputDevicePriorityKey(device.getAddress()), - priority); - } - - /*package*/synchronized List<BluetoothDevice> lookupInputDevicesMatchingStates(int[] states) { - List<BluetoothDevice> inputDevices = new ArrayList<BluetoothDevice>(); - - for (BluetoothDevice device: mInputDevices.keySet()) { - int inputDeviceState = getInputDeviceState(device); - for (int state : states) { - if (state == inputDeviceState) { - inputDevices.add(device); - break; - } - } - } - return inputDevices; - } - - private synchronized void handleInputDeviceStateChange(BluetoothDevice device, int state) { - int prevState; - if (mInputDevices.get(device) == null) { - prevState = BluetoothInputDevice.STATE_DISCONNECTED; - } else { - prevState = mInputDevices.get(device); - } - if (prevState == state) return; - - mInputDevices.put(device, state); - - if (getInputDevicePriority(device) > - BluetoothInputDevice.PRIORITY_OFF && - state == BluetoothInputDevice.STATE_CONNECTING || - state == BluetoothInputDevice.STATE_CONNECTED) { - // We have connected or attempting to connect. - // Bump priority - setInputDevicePriority(device, BluetoothInputDevice.PRIORITY_AUTO_CONNECT); - } - - Intent intent = new Intent(BluetoothInputDevice.ACTION_INPUT_DEVICE_STATE_CHANGED); - intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); - intent.putExtra(BluetoothInputDevice.EXTRA_PREVIOUS_INPUT_DEVICE_STATE, prevState); - intent.putExtra(BluetoothInputDevice.EXTRA_INPUT_DEVICE_STATE, state); - mContext.sendBroadcast(intent, BLUETOOTH_PERM); - - if (DBG) log("InputDevice state : device: " + device + " State:" + prevState + "->" + state); - sendConnectionStateChange(device, state, prevState); - } - - /*package*/ void handleInputDevicePropertyChange(String address, boolean connected) { - int state = connected ? BluetoothInputDevice.STATE_CONNECTED : - BluetoothInputDevice.STATE_DISCONNECTED; - BluetoothDevice device = mAdapter.getRemoteDevice(address); - handleInputDeviceStateChange(device, state); - } - - private void setInitialInputDevicePriority(BluetoothDevice device, int state) { - switch (state) { - case BluetoothDevice.BOND_BONDED: - if (getInputDevicePriority(device) == BluetoothInputDevice.PRIORITY_UNDEFINED) { - setInputDevicePriority(device, BluetoothInputDevice.PRIORITY_ON); - } - break; - case BluetoothDevice.BOND_NONE: - setInputDevicePriority(device, BluetoothInputDevice.PRIORITY_UNDEFINED); - break; - } - } - - /*package*/ boolean isRemoteDeviceInCache(String address) { - return (mDeviceProperties.get(address) != null); - } - /*package*/ String[] getRemoteDeviceProperties(String address) { if (!isEnabledInternal()) return null; @@ -2675,6 +2237,114 @@ public class BluetoothService extends IBluetooth.Stub { if (!result) log("Set Link Timeout to:" + num_slots + " slots failed"); } + /**** Handlers for PAN Profile ****/ + + public synchronized boolean isTetheringOn() { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + return mBluetoothPanProfileHandler.isTetheringOn(); + } + + /*package*/ synchronized boolean allowIncomingTethering() { + return mBluetoothPanProfileHandler.allowIncomingTethering(); + } + + public synchronized void setBluetoothTethering(boolean value) { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + mBluetoothPanProfileHandler.setBluetoothTethering(value); + } + + public synchronized int getPanDeviceState(BluetoothDevice device) { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + return mBluetoothPanProfileHandler.getPanDeviceState(device); + } + + public synchronized boolean connectPanDevice(BluetoothDevice device) { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, + "Need BLUETOOTH_ADMIN permission"); + return mBluetoothPanProfileHandler.connectPanDevice(device); + } + + public synchronized List<BluetoothDevice> getConnectedPanDevices() { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + return mBluetoothPanProfileHandler.getConnectedPanDevices(); + } + + public synchronized boolean disconnectPanDevice(BluetoothDevice device) { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, + "Need BLUETOOTH_ADMIN permission"); + return mBluetoothPanProfileHandler.disconnectPanDevice(device); + } + + /*package*/ synchronized void handlePanDeviceStateChange(BluetoothDevice device, + String iface, + int state, + int role) { + mBluetoothPanProfileHandler.handlePanDeviceStateChange(device, iface, state, role); + } + + /*package*/ synchronized void handlePanDeviceStateChange(BluetoothDevice device, + int state, int role) { + mBluetoothPanProfileHandler.handlePanDeviceStateChange(device, null, state, role); + } + + /**** Handlers for Input Device Profile ****/ + + public synchronized boolean connectInputDevice(BluetoothDevice device) { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, + "Need BLUETOOTH_ADMIN permission"); + BluetoothDeviceProfileState state = mDeviceProfileState.get(device.getAddress()); + return mBluetoothInputProfileHandler.connectInputDevice(device, state); + } + + public synchronized boolean connectInputDeviceInternal(BluetoothDevice device) { + return mBluetoothInputProfileHandler.connectInputDeviceInternal(device); + } + + public synchronized boolean disconnectInputDevice(BluetoothDevice device) { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, + "Need BLUETOOTH_ADMIN permission"); + BluetoothDeviceProfileState state = mDeviceProfileState.get(device.getAddress()); + return mBluetoothInputProfileHandler.disconnectInputDevice(device, state); + } + + public synchronized boolean disconnectInputDeviceInternal(BluetoothDevice device) { + return mBluetoothInputProfileHandler.disconnectInputDeviceInternal(device); + } + + public synchronized int getInputDeviceState(BluetoothDevice device) { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + return mBluetoothInputProfileHandler.getInputDeviceState(device); + + } + + public synchronized List<BluetoothDevice> getConnectedInputDevices() { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + return mBluetoothInputProfileHandler.getConnectedInputDevices(); + } + + public synchronized int getInputDevicePriority(BluetoothDevice device) { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + return mBluetoothInputProfileHandler.getInputDevicePriority(device); + } + + public synchronized boolean setInputDevicePriority(BluetoothDevice device, int priority) { + mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, + "Need BLUETOOTH_ADMIN permission"); + return mBluetoothInputProfileHandler.setInputDevicePriority(device, priority); + } + + /*package*/synchronized List<BluetoothDevice> lookupInputDevicesMatchingStates(int[] states) { + return mBluetoothInputProfileHandler.lookupInputDevicesMatchingStates(states); + } + + /*package*/ synchronized void handleInputDevicePropertyChange(String address, boolean connected) { + mBluetoothInputProfileHandler.handleInputDevicePropertyChange(address, connected); + } + + /*package*/ boolean isRemoteDeviceInCache(String address) { + return (mDeviceProperties.get(address) != null); + } + public boolean connectHeadset(String address) { if (getBondState(address) != BluetoothDevice.BOND_BONDED) return false; @@ -2928,12 +2598,14 @@ public class BluetoothService extends IBluetooth.Stub { short channel); private native boolean removeServiceRecordNative(int handle); private native boolean setLinkTimeoutNative(String path, int num_slots); - private native boolean connectInputDeviceNative(String path); - private native boolean disconnectInputDeviceNative(String path); - - private native boolean setBluetoothTetheringNative(boolean value, String nap, String bridge); - private native boolean connectPanDeviceNative(String path, String dstRole); - private native boolean disconnectPanDeviceNative(String path); + native boolean connectInputDeviceNative(String path); + native boolean disconnectInputDeviceNative(String path); + + native boolean setBluetoothTetheringNative(boolean value, String nap, String bridge); + native boolean connectPanDeviceNative(String path, String dstRole); + native boolean disconnectPanDeviceNative(String path); + native boolean disconnectPanServerDeviceNative(String path, + String address, String iface); private native int[] addReservedServiceRecordsNative(int[] uuuids); private native boolean removeReservedServiceRecordsNative(int[] handles); diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java index 190c0fc..072992e 100644 --- a/core/java/android/widget/AdapterViewAnimator.java +++ b/core/java/android/widget/AdapterViewAnimator.java @@ -279,6 +279,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter> * * @param whichChild the index of the child view to display */ + @android.view.RemotableViewMethod public void setDisplayedChild(int whichChild) { setDisplayedChild(whichChild, true); } diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 482ce56..c854fac 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -1056,24 +1056,34 @@ public class RemoteViews implements Parcelable, Filter { } /** - * Equivalent to calling {@link AdapterViewFlipper#showNext()} + * Equivalent to calling {@link AdapterViewAnimator#showNext()} * - * @param viewId The id of the view on which to call {@link AdapterViewFlipper#showNext()} + * @param viewId The id of the view on which to call {@link AdapterViewAnimator#showNext()} */ public void showNext(int viewId) { addAction(new ReflectionActionWithoutParams(viewId, "showNext")); } /** - * Equivalent to calling {@link AdapterViewFlipper#showPrevious()} + * Equivalent to calling {@link AdapterViewAnimator#showPrevious()} * - * @param viewId The id of the view on which to call {@link AdapterViewFlipper#showPrevious()} + * @param viewId The id of the view on which to call {@link AdapterViewAnimator#showPrevious()} */ public void showPrevious(int viewId) { addAction(new ReflectionActionWithoutParams(viewId, "showPrevious")); } /** + * Equivalent to calling {@link AdapterViewAnimator#setDisplayedChild(int)} + * + * @param viewId The id of the view on which to call + * {@link AdapterViewAnimator#setDisplayedChild(int)} + */ + public void setDisplayedChild(int viewId, int childIndex) { + setInt(viewId, "setDisplayedChild", childIndex); + } + + /** * Equivalent to calling View.setVisibility * * @param viewId The id of the view whose visibility should change diff --git a/core/java/android/widget/ViewAnimator.java b/core/java/android/widget/ViewAnimator.java index 7b66893..3c683d6 100644 --- a/core/java/android/widget/ViewAnimator.java +++ b/core/java/android/widget/ViewAnimator.java @@ -96,6 +96,7 @@ public class ViewAnimator extends FrameLayout { * * @param whichChild the index of the child view to display */ + @android.view.RemotableViewMethod public void setDisplayedChild(int whichChild) { mWhichChild = whichChild; if (whichChild >= getChildCount()) { @@ -122,6 +123,7 @@ public class ViewAnimator extends FrameLayout { /** * Manually shows the next child. */ + @android.view.RemotableViewMethod public void showNext() { setDisplayedChild(mWhichChild + 1); } @@ -129,6 +131,7 @@ public class ViewAnimator extends FrameLayout { /** * Manually shows the previous child. */ + @android.view.RemotableViewMethod public void showPrevious() { setDisplayedChild(mWhichChild - 1); } diff --git a/core/jni/android_server_BluetoothService.cpp b/core/jni/android_server_BluetoothService.cpp index 2c39871..bf0504f 100644 --- a/core/jni/android_server_BluetoothService.cpp +++ b/core/jni/android_server_BluetoothService.cpp @@ -1214,6 +1214,45 @@ static jboolean disconnectPanDeviceNative(JNIEnv *env, jobject object, return JNI_FALSE; } +static jboolean disconnectPanServerDeviceNative(JNIEnv *env, jobject object, + jstring path, jstring address, + jstring iface) { + LOGV(__FUNCTION__); +#ifdef HAVE_BLUETOOTH + LOGE("disconnectPanServerDeviceNative"); + native_data_t *nat = get_native_data(env, object); + jobject eventLoop = env->GetObjectField(object, field_mEventLoop); + struct event_loop_native_data_t *eventLoopNat = + get_EventLoop_native_data(env, eventLoop); + + if (nat && eventLoopNat) { + const char *c_address = env->GetStringUTFChars(address, NULL); + const char *c_path = env->GetStringUTFChars(path, NULL); + const char *c_iface = env->GetStringUTFChars(iface, NULL); + + int len = env->GetStringLength(path) + 1; + char *context_path = (char *)calloc(len, sizeof(char)); + strlcpy(context_path, c_path, len); // for callback + + bool ret = dbus_func_args_async(env, nat->conn, -1, + onPanDeviceConnectionResult, + context_path, eventLoopNat, + get_adapter_path(env, object), + DBUS_NETWORKSERVER_IFACE, + "DisconnectDevice", + DBUS_TYPE_STRING, &c_address, + DBUS_TYPE_STRING, &c_iface, + DBUS_TYPE_INVALID); + + env->ReleaseStringUTFChars(address, c_address); + env->ReleaseStringUTFChars(iface, c_iface); + env->ReleaseStringUTFChars(path, c_path); + return ret ? JNI_TRUE : JNI_FALSE; + } +#endif + return JNI_FALSE; +} + static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ {"classInitNative", "()V", (void*)classInitNative}, @@ -1274,6 +1313,8 @@ static JNINativeMethod sMethods[] = { {"connectPanDeviceNative", "(Ljava/lang/String;Ljava/lang/String;)Z", (void *)connectPanDeviceNative}, {"disconnectPanDeviceNative", "(Ljava/lang/String;)Z", (void *)disconnectPanDeviceNative}, + {"disconnectPanServerDeviceNative", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", + (void *)disconnectPanServerDeviceNative}, }; diff --git a/core/res/res/anim/wallpaper_intra_close_enter.xml b/core/res/res/anim/wallpaper_intra_close_enter.xml index e05345d..a499a09 100644 --- a/core/res/res/anim/wallpaper_intra_close_enter.xml +++ b/core/res/res/anim/wallpaper_intra_close_enter.xml @@ -19,16 +19,16 @@ <set xmlns:android="http://schemas.android.com/apk/res/android" android:detachWallpaper="true" android:shareInterpolator="false"> - <scale android:fromXScale="1.0" android:toXScale="1.0" - android:fromYScale=".9" android:toYScale="1.0" + <scale android:fromXScale=".95" android:toXScale="1.0" + android:fromYScale=".95" android:toYScale="1.0" android:pivotX="50%p" android:pivotY="50%p" android:fillEnabled="true" android:fillBefore="true" android:interpolator="@interpolator/decelerate_quint" - android:startOffset="200" + android:startOffset="160" android:duration="300" /> <alpha android:fromAlpha="0" android:toAlpha="1.0" android:fillEnabled="true" android:fillBefore="true" - android:interpolator="@interpolator/decelerate_quint" - android:startOffset="200" + android:interpolator="@interpolator/decelerate_cubic" + android:startOffset="160" android:duration="300"/> -</set> +</set>
\ No newline at end of file diff --git a/core/res/res/anim/wallpaper_intra_close_exit.xml b/core/res/res/anim/wallpaper_intra_close_exit.xml index df7acc9..12a8df5 100644 --- a/core/res/res/anim/wallpaper_intra_close_exit.xml +++ b/core/res/res/anim/wallpaper_intra_close_exit.xml @@ -19,14 +19,14 @@ <set xmlns:android="http://schemas.android.com/apk/res/android" android:detachWallpaper="true" android:shareInterpolator="false"> - <scale android:fromXScale="1.0" android:toXScale="0.9" - android:fromYScale="1.0" android:toYScale="0.9" + <scale android:fromXScale="1.0" android:toXScale="1.0" + android:fromYScale="1.0" android:toYScale="0.0" android:pivotX="50%p" android:pivotY="50%p" android:fillEnabled="true" android:fillAfter="true" - android:interpolator="@interpolator/decelerate_quint" + android:interpolator="@interpolator/linear" android:duration="300" /> <alpha android:fromAlpha="1.0" android:toAlpha="0" - android:fillEnabled="true" android:fillAfter="true" + android:fillEnabled="true" android:fillAfter="true" android:interpolator="@interpolator/decelerate_cubic" - android:duration="150"/> -</set> + android:duration="120"/> +</set>
\ No newline at end of file diff --git a/core/res/res/anim/wallpaper_intra_open_enter.xml b/core/res/res/anim/wallpaper_intra_open_enter.xml index ff310a1..a499a09 100644 --- a/core/res/res/anim/wallpaper_intra_open_enter.xml +++ b/core/res/res/anim/wallpaper_intra_open_enter.xml @@ -19,14 +19,16 @@ <set xmlns:android="http://schemas.android.com/apk/res/android" android:detachWallpaper="true" android:shareInterpolator="false"> - <scale android:fromXScale="0.95" android:toXScale="1.0" - android:fromYScale="0.95" android:toYScale="1.0" + <scale android:fromXScale=".95" android:toXScale="1.0" + android:fromYScale=".95" android:toYScale="1.0" android:pivotX="50%p" android:pivotY="50%p" + android:fillEnabled="true" android:fillBefore="true" android:interpolator="@interpolator/decelerate_quint" - android:startOffset="200" + android:startOffset="160" android:duration="300" /> <alpha android:fromAlpha="0" android:toAlpha="1.0" + android:fillEnabled="true" android:fillBefore="true" android:interpolator="@interpolator/decelerate_cubic" - android:startOffset="200" + android:startOffset="160" android:duration="300"/> -</set> +</set>
\ No newline at end of file diff --git a/core/res/res/anim/wallpaper_intra_open_exit.xml b/core/res/res/anim/wallpaper_intra_open_exit.xml index 47ea0b4..12a8df5 100644 --- a/core/res/res/anim/wallpaper_intra_open_exit.xml +++ b/core/res/res/anim/wallpaper_intra_open_exit.xml @@ -22,9 +22,11 @@ <scale android:fromXScale="1.0" android:toXScale="1.0" android:fromYScale="1.0" android:toYScale="0.0" android:pivotX="50%p" android:pivotY="50%p" + android:fillEnabled="true" android:fillAfter="true" android:interpolator="@interpolator/linear" android:duration="300" /> <alpha android:fromAlpha="1.0" android:toAlpha="0" + android:fillEnabled="true" android:fillAfter="true" android:interpolator="@interpolator/decelerate_cubic" - android:duration="160"/> -</set> + android:duration="120"/> +</set>
\ No newline at end of file diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java index 1ecf103..3667c7b 100644 --- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java +++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java @@ -46,8 +46,8 @@ import java.util.List; * <accesspoint></accesspoint>. The supported configuration includes: ssid, * security, eap, phase2, identity, password, anonymousidentity, cacert, usercert, * in which each is included in the corresponding tags. Static IP setting is also supported. - * Tags that can be used include: ip, gateway, netmask, dns1, dns2. All access points have to be - * enclosed in tags of <resources></resources>. + * Tags that can be used include: ip, gateway, networkprefixlength, dns1, dns2. All access points + * have to be enclosed in tags of <resources></resources>. * * The following is a sample configuration file for an access point using EAP-PEAP with MSCHAP2. * <resources> @@ -62,7 +62,8 @@ import java.util.List; * </resources> * * Note:ssid and security have to be the first two tags - * for static ip setting, tag "ip" should be listed before other fields: dns, gateway, netmask. + * for static ip setting, tag "ip" should be listed before other fields: dns, gateway, + * networkprefixlength. */ public class AccessPointParserHelper { private static final String KEYSTORE_SPACE = "keystore://"; @@ -106,7 +107,6 @@ public class AccessPointParserHelper { boolean ip = false; boolean gateway = false; boolean networkprefix = false; - boolean netmask = false; boolean dns1 = false; boolean dns2 = false; boolean eap = false; @@ -163,9 +163,6 @@ public class AccessPointParserHelper { if (tagName.equalsIgnoreCase("networkprefixlength")) { networkprefix = true; } - if (tagName.equalsIgnoreCase("netmask")) { - netmask = true; - } if (tagName.equalsIgnoreCase("dns1")) { dns1 = true; } @@ -321,19 +318,6 @@ public class AccessPointParserHelper { } networkprefix = false; } - if (netmask) { - try { - String netMaskStr = new String(ch, start, length); - if (!InetAddress.isNumeric(netMaskStr)) { - throw new SAXException(); - } - InetAddress netMaskAddr = InetAddress.getByName(netMaskStr); - mLinkProperties.addLinkAddress(new LinkAddress(mInetAddr, netMaskAddr)); - } catch (UnknownHostException e) { - throw new SAXException(); - } - netmask = false; - } if (dns1) { try { String dnsAddr = new String(ch, start, length); diff --git a/docs/html/guide/appendix/market-filters.jd b/docs/html/guide/appendix/market-filters.jd index 6ca8acc..f826f43 100644 --- a/docs/html/guide/appendix/market-filters.jd +++ b/docs/html/guide/appendix/market-filters.jd @@ -5,23 +5,25 @@ page.title=Market Filters <div id="qv"> <h2>Quickview</h2> -<ul> <li>Android Market applies filters to that let you control whether your app is shown to a -user who is browing or searching for apps.</li> -<li>Filtering is determined by elements in an app's manifest file, -aspects of the device being used, and other factors.</li> </ul> +<ul> +<li>Android Market applies filters that control which Android-powered devices can access your +application on Market.</li> +<li>Filtering is determined by comparing device configurations that you declare in you app's +manifest file to the configurations defined by the device, as well as other factors.</li> </ul> <h2>In this document</h2> <ol> <li><a href="#how-filters-work">How Filters Work in Android Market</a></li> <li><a href="#manifest-filters">Filtering based on Manifest File Elements</a></li> <li><a href="#other-filters">Other Filters</a></li> +<li><a href="#advanced-filters">Advanced Manifest Filters</a></li> </ol> <h2>See also</h2> <ol> <li><a -href="{@docRoot}guide/practices/compatibility.html">Compatibility</a></li> -<li style="margin-top:2px;"><code><a +href="{@docRoot}guide/practices/compatibility.html">Android Compatibility</a></li> +<li><code><a href="{@docRoot}guide/topics/manifest/supports-screens-element.html"><supports-screens></a></code></li> <li><code><a href="{@docRoot}guide/topics/manifest/uses-configuration-element.html"><uses-configuration></a></code></li> @@ -42,36 +44,40 @@ publishing your app on Android Market?</p> <a id="publish-link" href="http://market.android.com/publish">Go to Android Market »</a> </div> </div> -</div> </div> +</div> +</div> + -<p>When a user searches or browses in Android Market, the results are filtered, and -some applications might not be visible. For example, if an application requires a +<p>When a user searches or browses in Android Market, the results are filtered based on which +applications are compatible with the user's device. For example, if an application requires a trackball (as specified in the manifest file), then Android Market will not show -the app on any device that does not have a trackball.</p> <p>The manifest file and -the device's hardware and features are only part of how applications are filtered -— filtering also depends on the country and carrier, the presence or absence -of a SIM card, and other factors. </p> +the app on any device that does not have a trackball.</p> + +<p>The manifest file and the device's hardware and features are only part of how applications are +filtered—filtering might also depend on the country and carrier, the presence or absence of a +SIM card, and other factors. </p> <p>Changes to the Android Market filters are independent of changes to the Android platform itself. This document will be updated periodically to reflect -any changes that occur. </p> +any changes that affect the way Android Market filters applications.</p> + <h2 id="how-filters-work">How Filters Work in Android Market</h2> <p>Android Market uses the filter restrictions described below to determine whether to show your application to a user who is browsing or searching for -applications on a given device. When determining whether to display your app, +applications on an Android-powered device. When determining whether to display your app, Market checks the device's hardware and software capabilities, as well as it's carrier, location, and other characteristics. It then compares those against the restrictions and dependencies expressed by the application itself, in its -manifest, <code>.apk</code>, and publishing details. If the application is +manifest file and publishing details. If the application is compatible with the device according to the filter rules, Market displays the application to the user. Otherwise, Market hides your application from search results and category browsing. </p> -<p> You can use the filters described below to control whether Market shows or -hides your application to users. You can request any combination of the -available filters for your app — for example, you could set a +<p>You can use the filters described below to control whether Market shows or +hides your application to users. You can use any combination of the +available filters for your app—for example, you can set a <code>minSdkVersion</code> requirement of <code>"4"</code> and set <code>smallScreens="false"</code> in the app, then when uploading the app to Market you could target European countries (carriers) only. Android Market's @@ -92,16 +98,18 @@ makes the app invisible to the user, the user will not see that an upgrade is available. </li> </ul> + + <h2 id="manifest-filters">Filtering based on Manifest Elements</h2> <p>Most Market filters are triggered by elements within an application's manifest file, <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">AndroidManifest.xml</a>, -although not everything in the manifest file can trigger filtering. The -table below lists the manifest elements that you can use to trigger Android -Market filtering, and explains how the filtering works.</p> +although not everything in the manifest file can trigger filtering. +Table 1 lists the manifest elements that you should use to trigger Android +Market filtering, and explains how the filtering for each element works.</p> -<p class="table-caption"><strong>Table 1.</strong> Manifest elements that +<p id="table1" class="table-caption"><strong>Table 1.</strong> Manifest elements that trigger filtering on Market.</p> <table> <tr> @@ -313,10 +321,13 @@ href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#max"><code>android:m </tr> </table> + <h2 id="other-filters">Other Filters</h2> + <p>Android Market uses other application characteristics to determine whether to show or hide an application for a particular user on a given device, as described in the table below. </p> -<p class="table-caption"><strong>Table 2.</strong> Application and publishing characteristics that affect filtering on Market.</p> +<p id="table2" class="table-caption"><strong>Table 2.</strong> Application and publishing +characteristics that affect filtering on Market.</p> <table> <tr> <th>Filter Name</th> <th>How It Works</th> </tr> @@ -351,3 +362,38 @@ country (as determined by SIM carrier) in which paid apps are available.</p></td developer devices or unreleased devices.</p></td> </tr> </table> + + +<h2 id="advanced-filters">Advanced Manifest Filters</h2> + +<p>In addition to the manifest elements in <a href="#table1">table 1</a>, Android Market can also +filter applications based on the advanced manifest elements in table 3.</p> + +<p>These manifest elements and the filtering they trigger are for exceptional use-cases +only. They are designed for some types of high-performance games and similar applications that +require strict controls on application distribution. <strong>Most applications should never use +these filters</strong>.</p> + +<p id="table3" class="table-caption"><strong>Table 3.</strong> Advanced manifest elements for +Android Market filtering.</p> +<table> + <tr><th>Manifest Element</th><th>Summary</th></tr> + <tr> + <td><nobr><a href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code +<compatible-screens>}</a></nobr></td> + <td> + <p>Android Market filters the application if the device screen size and density does not match +any of the screen configurations (declared by a {@code <screen>} element) in the {@code +<compatible-screens>} element.</p> + <p class="caution"><strong>Caution:</strong> Normally, <strong>you should not use +this manifest element</strong>. Using this element can dramatically +reduce the potential user base for your application, by excluding all combinations of screen size +and density that you have not listed. You should instead use the <a +href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code +<supports-screens>}</a> manifest element (described above in <a href="#table1">table +1</a>) to enable screen compatibility mode for screen configurations you have not accounted for +with alternative resources.</p> + </td> + </tr> +</table> + diff --git a/docs/html/guide/developing/testing/index.jd b/docs/html/guide/developing/testing/index.jd index 8ffaf58..8a08959 100644 --- a/docs/html/guide/developing/testing/index.jd +++ b/docs/html/guide/developing/testing/index.jd @@ -18,14 +18,14 @@ page.title=Testing which guides you through a more complex testing scenario. </p> <dl> - <dt><a href="testing_eclipse.html">Testing in Eclipse, with ADT</a></dt> + <dt><a href="testing_eclipse.html">Testing from Eclipse, with ADT</a></dt> <dd> The ADT plugin lets you quickly set up and manage test projects directly in the Eclipse UI. Once you have written your tests, you can build and run them and then see the results in the Eclipse JUnit view. You can also use the SDK command-line tools to execute your tests if needed. </dd> - <dt><a href="testing_otheride.html">Testing in Other IDEs</a></dt> + <dt><a href="testing_otheride.html">Testing from Other IDEs</a></dt> <dd> The SDK command-line tools provide the same capabilities as the ADT plugin. You can use them to set up and manage test projects, build your test application, diff --git a/docs/html/guide/developing/tools/monkeyrunner_concepts.jd b/docs/html/guide/developing/tools/monkeyrunner_concepts.jd index d648b93..658ff75 100644 --- a/docs/html/guide/developing/tools/monkeyrunner_concepts.jd +++ b/docs/html/guide/developing/tools/monkeyrunner_concepts.jd @@ -110,8 +110,17 @@ device = MonkeyRunner.waitForConnection() # to see if the installation worked. device.installPackage('myproject/bin/MyApplication.apk') -# Runs an activity in the application -device.startActivity(component='com.example.android.myapplication.MainActivity') +# sets a variable with the package's internal name +package = 'com.example.android.myapplication' + +# sets a variable with the name of an Activity in the package +activity = 'com.example.android.myapplication.MainActivity' + +# sets the name of the component to start +runComponent = package + '/' + activity + +# Runs the component +device.startActivity(component=runComponent) # Presses the Menu button device.press('KEYCODE_MENU','DOWN_AND_UP') diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs index 0ea4b83..24ccfdb 100644 --- a/docs/html/guide/guide_toc.cs +++ b/docs/html/guide/guide_toc.cs @@ -65,6 +65,9 @@ <li><a href="<?cs var:toroot ?>guide/topics/fundamentals/fragments.html"> <span class="en">Fragments</span> </a> <span class="new">new!</span></li> + <li><a href="<?cs var:toroot ?>guide/topics/providers/loaders.html"> + <span class="en">Loaders</span> + </a><span class="new">new!</span></li> <li><a href="<?cs var:toroot ?>guide/topics/fundamentals/tasks-and-back-stack.html"> <span class="en">Tasks and Back Stack</span> </a></li> @@ -95,8 +98,9 @@ <ul> <li class="toggle-list"> <div><a href="<?cs var:toroot ?>guide/topics/ui/index.html"> - <span class="en">User Interface</span> - </a></div> + <span class="en">User Interface</span> + </a> + <span class="new">more!</span></div> <ul> <li><a href="<?cs var:toroot ?>guide/topics/ui/declaring-layout.html"> <span class="en">Declaring Layout</span> @@ -207,6 +211,7 @@ <li><a href="<?cs var:toroot ?>guide/topics/manifest/activity-alias-element.html"><activity-alias></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/application-element.html"><application></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/category-element.html"><category></a></li> + <li><a href="<?cs var:toroot ?>guide/topics/manifest/compatible-screens-element.html"><compatible-screens></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/data-element.html"><data></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/instrumentation-element.html"><instrumentation></a></li> @@ -233,8 +238,9 @@ <ul> <li class="toggle-list"> <div><a href="<?cs var:toroot ?>guide/topics/graphics/index.html"> - <span class="en">Graphics</span> - </a></div> + <span class="en">Graphics</span> + </a> + <span class="new">more!</span></div> <ul> <li><a href="<?cs var:toroot ?>guide/topics/graphics/2d-graphics.html"> <span class="en">2D Graphics</span> @@ -253,15 +259,15 @@ </a></li> </ul> </li> + <li><a href="<?cs var:toroot ?>guide/topics/media/index.html"> + <span class="en">Audio and Video</span> + </a></li> <li> <a href="<?cs var:toroot ?>guide/topics/clipboard/copy-paste.html"> - <span class="en">Copying and Pasting</span> + <span class="en">Copy and Paste</span> </a> <span class="new">new!</span> </li> - <li><a href="<?cs var:toroot ?>guide/topics/media/index.html"> - <span class="en">Audio and Video</span> - </a></li> <!--<li class="toggle-list"> <div><a style="color:gray;">Sensors</a></div> <ul> diff --git a/docs/html/guide/topics/clipboard/copy-paste.jd b/docs/html/guide/topics/clipboard/copy-paste.jd index 9a50a35..6c86f47 100644 --- a/docs/html/guide/topics/clipboard/copy-paste.jd +++ b/docs/html/guide/topics/clipboard/copy-paste.jd @@ -1,4 +1,4 @@ -page.title=Copying and Pasting +page.title=Copy and Paste @jd:body <div id="qv-wrapper"> <div id="qv"> diff --git a/docs/html/guide/topics/manifest/compatible-screens-element.jd b/docs/html/guide/topics/manifest/compatible-screens-element.jd new file mode 100644 index 0000000..9fb0fd2 --- /dev/null +++ b/docs/html/guide/topics/manifest/compatible-screens-element.jd @@ -0,0 +1,108 @@ +page.title=<compatible-screens> +@jd:body + +<dl class="xml"> +<dt>syntax:</dt> +<dd> +<pre> +<<a href="#compatible-screens">compatible-screens</a>> + <<a href="#screen">screen</a> android:<a href="#screenSize">screenSize</a>=["small" | "normal" | "large" | "xlarge"] + android:<a href="#screenDensity">screenDensity</a>=["ldpi" | "mdpi" | "hdpi" | "xhdpi"] /> + ... +</compatible-screens> +</pre> +</dd> + +<dt>contained in:</dt> +<dd><code><a +href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code></dd> + +<dt>description:</dt> +<dd>Specifies each screen configuration with which the application is compatible. Only one instance +of the {@code <compatible-screens>} element is allowed in the manifest, but it can +contain multiple <code><screen></code> elements. Each <code><screen></code> element +specifies a specific screen size-density combination with which the application is compatible. + + <p>The Android system <em>does not</em> read the {@code <compatible-screens>} manifest +element (neither at install-time nor at runtime). This element is informational only and may be used +by external services (such as Android Market) to better understand the application's compatibility +with specific screen configurations and enable filtering for users. Any screen configuration that is +<em>not</em> declared in this element is a screen with which the application is <em>not</em> +compatible. Thus, external services (such as Android Market) should not provide the application to +devices with such screens.</p> + + <p class="caution"><strong>Caution:</strong> Normally, <strong>you should not use this manifest +element</strong>. Using this element can dramatically reduce the potential user base for your +application, by not allowing users to install your application if they have a device with a screen +configuration that you have not listed. You should use it only as a last resort, when the +application absolutely does not work with all screen configurations. Instead of using this element, +you should follow the guide to <a href="{@docRoot}guide/practices/screens_support.html">Supporting +Multiple Screens</a>, in order to provide complete support for multiple screens, by adding +alternative resources for different screen sizes and densities.</p> + + <p>If you want to set only a minimum screen <em>size</em> for your your application, then you +should use the <a href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code +<supports-screens>}</a> element. For example, if you want your application to be available +only for <em>large</em> and <em>xlarge</em> screen devices, the <a +href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code +<supports-screens>}</a> element allows you to declare that your application does not +support <em>small</em> and <em>normal</em> screen sizes. External services (such as Android +Market) will filter your application accordingly. You can also use the <a +href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code +<supports-screens>}</a> element to declare whether the system should resize your +application for different screen sizes.</p> + + <p>Also see the <a href="{@docRoot}guide/appendix/market-filters.html">Market Filters</a> +document for more information about how Android Market filters applications using this and +other manifest elements.</p> + +</dd> + +<dt>child elements:</dt> +<dd> + <dl class="tag-list"> + + <dt id="screen">{@code <screen>}</dt> + <dd>Specifies a single screen configuration with which the application is compatible. + <p>At least one instance of this element must be placed inside the {@code +<compatible-screens>} element. This element <em>must include both</em> the {@code +android:screenSize} and {@code android:screenDensity} attributes (if you do not declare both +attributes, then the element is ignored).</p> + + <p class="caps">attributes:</p> + <dl class="atn-list"> + <dt id="screenSize"><code>android:screenSize</code></dt> + <dd><b>Required.</b> Specifies the screen size for this screen configuration. + <p>Accepted values:</p> + <ul> + <li>{@code small}</li> + <li>{@code normal}</li> + <li>{@code large}</li> + <li>{@code xlarge}</li> + </ul> + <p>For information about the different screen sizes, see <a +href="{@docRoot}guide/practices/screens_support.html#range">Supporting Multiple Screens</a>.</p> + </dd> + <dt id="screenDensity"><code>android:screenDensity</code></dt> + <dd><b>Required.</b> Specifies the screen density for this screen configuration. + <p>Accepted values:</p> + <ul> + <li>{@code ldpi}</li> + <li>{@code mdpi}</li> + <li>{@code hdpi}</li> + <li>{@code xhdpi}</li> + </ul> + <p>For information about the different screen densities, see <a +href="{@docRoot}guide/practices/screens_support.html#range">Supporting Multiple Screens</a>.</p> + </dd> + </dl> + </dd> + </dl> +</dd> +<dt>introduced in:</dt> +<dd>API Level 9</dd> +<dt>see also:</dt> +<dd><a +href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a></dd> +<dd><a href="{@docRoot}guide/appendix/market-filters.html">Market Filters</a></dd> +</dl> diff --git a/docs/html/guide/topics/manifest/supports-screens-element.jd b/docs/html/guide/topics/manifest/supports-screens-element.jd index 64a7a58..92c769e 100644 --- a/docs/html/guide/topics/manifest/supports-screens-element.jd +++ b/docs/html/guide/topics/manifest/supports-screens-element.jd @@ -6,7 +6,8 @@ page.title=<supports-screens> <dt>syntax:</dt> <dd> <pre class="stx"> -<supports-screens android:<a href="#small">smallScreens</a>=["true" | "false"] +<supports-screens android:<a href="#resizeable">resizeable</a>=["true" | "false"] + android:<a href="#small">smallScreens</a>=["true" | "false"] android:<a href="#normal">normalScreens</a>=["true" | "false"] android:<a href="#large">largeScreens</a>=["true" | "false"] android:<a href="#xlarge">xlargeScreens</a>=["true" | "false"] @@ -19,17 +20,33 @@ page.title=<supports-screens> <dt>description:</dt> <dd>Lets you specify the screen dimensions the -application supports. By default a modern application (using API Level 4 or higher) supports all -screen sizes and must explicitly disable certain screen sizes here; -older applications are assumed to support only the "normal" -screen size. Note that screen size is a separate axis from -density. Screen size is determined as the available pixels to an application -after density scaling has been applied. - -<p>Based on the target device screen density, the Android -framework will scale down assets by a factor of 0.75 (low dpi screens) -or scale them up by a factor of 1.5 (high dpi screens). -The screen density is expressed as dots-per-inch (dpi).</p> +application supports. By default, a modern application (using API Level 4 or higher) supports all +screen sizes; older applications are assumed to support only the "normal" screen size. Screen +size is determined as the available pixels to an application after density scaling has been +applied. (Note that screen size is a separate axis from screen density.) + +<p>An application "supports" a given screen size if it fills the entire screen and works as +expected. By default, the system will resize your application to fill the screen, if you have set +either <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code +minSdkVersion}</a> or <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code +targetSdkVersion}</a> to {@code "4"} or higher. Resizing works well for most applications and +you don't have to do any extra work to make your application work on larger screens.</p> + +<p>In addition to allowing the system to resize your application, you can add additional support +for different screen sizes by providing <a +href="{@docRoot}guide/topics/resources/providing-resources.html#AlternativeResources">alternative +layout resources</a> for different sizes. For instance, you might want to modify the layout +of an activity when it is on a tablet or similar device that has an <em>xlarge</em> screen.</p> + +<p>If your application does not support <em>large</em> or <em>xlarge</em> screens, then you should +declare that it is not resizeable by setting <a href="#resizeable">{@code android:resizeable}</a> to +{@code "false"}, so that the system will not resize your application on larger screens.</p> + +<p>If your application does not support <em>small</em> screens, then +there isn't much the system can do to make the application work well on a smaller screen, so +external services (such as Android Market) should not allow users to install the application on such +screens.</p> + <p>For more information, see <a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a>.</p> @@ -38,16 +55,40 @@ The screen density is expressed as dots-per-inch (dpi).</p> <dt>attributes:</dt> <dd> -<dl class="attr"><dt><a name="small"></a>{@code android:smallScreens}</dt> +<dl class="attr"> + + <dt><a name="resizeable"></a>{@code android:resizeable}</dt> + <dd>Indicates whether the application is resizeable for different screen sizes. This attribute is +true, by default, if you have set either <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> or <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> to +{@code "4"} or higher. Otherwise, it is false by default. If set false, the system will not resize +your application when run on <em>large</em> or <em>xlarge</em> screens. Instead, the +application appears in a "postage stamp" that equals the <em>normal</em> screen size that your +application does support. This is less than an ideal experience for users, because the +application appears smaller than the available screen, but it might help your application run +normally if it were designed only for the <em>normal</em> screen size and some behaviors do not work +when resized.</p> + <p>To provide the best experience on all screen sizes, you should allow resizing and, if your +application does not work well on larger screens, follow the guide to <a +href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a> to enable +additional screen support.</p> + </dd> + + + <dt><a name="small"></a>{@code android:smallScreens}</dt> <dd>Indicates whether the application supports smaller screen form-factors. A small screen is defined as one with a smaller aspect ratio than the "normal" (traditional HVGA) screen. An application that does not support small screens <em>will not be available</em> for - small screen devices, because there is little the platform can do - to make such an application work on a smaller screen. If the application has set the <a -href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code <uses-sdk>}</a> element's -{@code android:minSdkVersion} or {@code android:targetSdkVersion} attribute to "4" or higher, -the default value for this is "true", any value less than "4" results in this set to "false". + small screen devices from external services (such as Android Market), because there is little +the platform can do + to make such an application work on a smaller screen. If the application has set either <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> or <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> to +{@code "4"} or higher, +the default value for this is {@code "true"}, any value less than {@code "4"} results in this set to +{@code "false"}. </dd> <dt><a name="normal"></a>{@code android:normalScreens}</dt> @@ -61,38 +102,44 @@ the default value for this is "true", any value less than "4" results in this se <dt><a name="large"></a>{@code android:largeScreens}</dt> <dd>Indicates whether the application supports larger screen form-factors. A large screen is defined as a screen that is significantly larger - than a "normal" phone screen, and thus may require some special care - on the application's part to make good use of it. An application that - does not support large screens (declares this "false")—but does support "normal" or -"small" screens—will be placed as a "postage stamp" on - a large screen, so that it retains the dimensions it was originally - designed for. If the application has set the <a -href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code <uses-sdk>}</a> element's -{@code android:minSdkVersion} or {@code android:targetSdkVersion} attribute to "4" or higher, -the default value for this is "true", any value less than "4" results in this set to "false". + than a "normal" phone screen, and thus might require some special care + on the application's part to make good use of it, though it may rely on resizing by the +system to fill the screen. If the application has set either <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> or <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> to +{@code "4"} or higher, +the default value for this is {@code "true"}, any value less than {@code "4"} results in this set to +{@code "false"}. </dd> - + <dt><a name="xlarge"></a>{@code android:xlargeScreens}</dt> <dd>Indicates whether the application supports extra large screen form-factors. An xlarge screen is defined as a screen that is significantly larger than a "large" screen, such as a tablet (or something larger) and may require special care - on the application's part to make good use of it. An application that - does not support xlarge screens (declares this "false")—but does support "large", -"normal", or "small" screens—will be placed as a "postage stamp" on - an xlarge screen, so that it retains the dimensions it was originally - designed for. If the application has set the <a -href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code <uses-sdk>}</a> element's -{@code android:minSdkVersion} or {@code android:targetSdkVersion} attribute to "4" or higher, -the default value for this is "true", any value less than "4" results in this set to "false". + on the application's part to make good use of it, though it may rely on resizing by the +system to fill the screen. If the application has set either <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> or <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> to +{@code "4"} or higher, +the default value for this is {@code "true"}, any value less than {@code "4"} results in this set to +{@code "false"}. <p>This attribute was introduced in API Level 9.</p> </dd> <dt><a name="any"></a>{@code android:anyDensity}</dt> <dd>Indicates whether the application includes resources to accommodate any screen density. Older applications (before API Level 4) are assumed unable to - accomodate all densities and this is "false" by default. Applications using - API Level 4 or higher are assumed able to and this is "true" by default. + accomodate all densities and this is {@code "false"} by default. If the application has set +either <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> or <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> to +{@code "4"} or higher, +the default value for this is {@code "true"}. Otherwise, it is {@code "false"}. You can explicitly supply your abilities here. + <p>Based on the "standard" device screen density (medium dpi), the Android framework will scale +down application assets by a factor of 0.75 (low dpi screens) or scale them up by a factor of 1.5 +(high dpi screens), when you don't provide alternative resources for a specifc screen density. The +screen density is expressed as dots-per-inch (dpi).</p> </dd> diff --git a/docs/html/guide/topics/manifest/uses-feature-element.jd b/docs/html/guide/topics/manifest/uses-feature-element.jd index 5242126..0828e8b 100644 --- a/docs/html/guide/topics/manifest/uses-feature-element.jd +++ b/docs/html/guide/topics/manifest/uses-feature-element.jd @@ -644,33 +644,46 @@ device.</td> </tr> <tr> - <td rowspan="4">Touchscreen</td> + <td rowspan="5">Touchscreen</td> + <td><code>android.hardware.faketouch</code></td> + <td>The application uses basic touch interaction events, such as "click down", "click +up", and drag.</td> + <td>When declared, this indicates that the application is compatible with a device that offers an +emulated touchscreen (or better). A device that offers an emulated touchscreen provides a user input +system that can emulate a subset of touchscreen capabilities. An example of such an input system is +a mouse or remote control that drives an on-screen cursor. If your application does not require +complicated gestures and you want your application available to devices with an emulated +touchscreen, you should declare this feature.</td> +</tr> +<tr> <td><code>android.hardware.touchscreen</code></td> - <td>The application uses touchscreen capabilities on the device.</td> + <td>The application uses touchscreen capabilities, for gestures more interactive +than basic touches, such as a fling. This is a superset of the faketouch features.</td> <td></td> </tr> <tr> <td><code>android.hardware.touchscreen.multitouch</code></td> - <td>Subfeature. The application uses basic two-point multitouch capabilities on the device -screen.</td> + <td>The application uses basic two-point multitouch capabilities on the device +screen, such as for pinch gestures, but does not need to track touches independently. This +is a superset of touchscreen features.</td> <td>If declared with the <code>"android:required="true"</code> attribute, this -subfeature implicitly declares the <code>android.hardware.touchscreen</code> +implicitly declares the <code>android.hardware.touchscreen</code> parent feature. </td> </tr> <tr> <td><code>android.hardware.touchscreen.multitouch.distinct</code></td> <td>Subfeature. The application uses advanced multipoint multitouch capabilities on the device screen, such as for tracking two or more points fully -independently.</td> +independently. This is a superset of multitouch features.</td> <td rowspan="2">If declared with the <code>"android:required="true"</code> attribute, this -subfeature implicitly declares the +implicitly declares the <code>android.hardware.touchscreen.multitouch</code> parent feature. </td> </tr> <tr> <td><code>android.hardware.touchscreen.multitouch.jazzhand</code></td> - <td>Subfeature. The application uses advanced multipoint multitouch + <td>The application uses advanced multipoint multitouch capabilities on the device screen, for tracking up to five points fully -independently.</td> +independently. This is a superset of distinct multitouch features.</td> </tr> <tr> diff --git a/docs/html/guide/topics/providers/loaders.jd b/docs/html/guide/topics/providers/loaders.jd new file mode 100644 index 0000000..c54656c --- /dev/null +++ b/docs/html/guide/topics/providers/loaders.jd @@ -0,0 +1,492 @@ +page.title=Using Loaders +@jd:body +<div id="qv-wrapper"> +<div id="qv"> + <h2>In this document</h2> + <ol> + <li><a href="#summary">Loader API Summary</a></li> + <li><a href="#app">Using Loaders in an Application</a> + <ol> + <li><a href="#requirements"></a></li> + <li><a href="#starting">Starting a Loader</a></li> + <li><a href="#restarting">Restarting a Loader</a></li> + <li><a href="#callback">Using the LoaderManager Callbacks</a></li> + </ol> + </li> + <li><a href="#example">Example</a> + <ol> + <li><a href="#more_examples">More Examples</a></li> + </ol> + </li> + </ol> + + <h2>Key classes</h2> + <ol> + <li>{@link android.app.LoaderManager}</li> + <li>{@link android.content.Loader}</li> + + </ol> + + <h2>Related samples</h2> + <ol> + <li> <a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/FragmentCursorLoader.html"> FragmentCursorLoader</a></li> + <li> <a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.html"> LoaderThrottle</a></li> + </ol> + </div> +</div> + +<p>Introduced in Android 3.0, loaders make it easy to asynchronously load data +in an activity or fragment. Loaders have these characteristics:</p> + <ul> + <li>They are available to every {@link android.app.Activity} and {@link +android.app.Fragment}.</li> + <li>They provide asynchronous loading of data.</li> + <li>They monitor the source of their data and deliver new results when the +content changes.</li> + <li>They automatically reconnect to the last loader's cursor when being +recreated after a configuration change. Thus, they don't need to re-query their +data.</li> + </ul> + +<h2 id="summary">Loader API Summary</h2> + +<p>There are multiple classes and interfaces that may be involved in using +loaders in an application. They are summarized in this table:</p> + +<table> + <tr> + <th>Class/Interface</th> + <th>Description</th> + </tr> + <tr> + <td>{@link android.app.LoaderManager}</td> + <td>An abstract class associated with an {@link android.app.Activity} or +{@link android.app.Fragment} for managing one or more {@link +android.content.Loader} instances. This helps an application manage +longer-running operations in conjunction with the {@link android.app.Activity} +or {@link android.app.Fragment} lifecycle; the most common use of this is with a +{@link android.content.CursorLoader}, however applications are free to write +their own loaders for loading other types of data. + <br /> + <br /> + There is only one {@link android.app.LoaderManager} per activity or fragment. But a {@link android.app.LoaderManager} can have +multiple loaders.</td> + </tr> + <tr> + <td>{@link android.app.LoaderManager.LoaderCallbacks}</td> + <td>A callback interface for a client to interact with the {@link +android.app.LoaderManager}. For example, you use the {@link +android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()} +callback method to create a new loader.</td> + </tr> + <tr> + <td>{@link android.content.Loader}</td> + <td>An abstract class that performs asynchronous loading of data. This is +the base class for a loader. You would typically use {@link +android.content.CursorLoader}, but you can implement your own subclass. While +loaders are active they should monitor the source of their data and deliver new +results when the contents change. </td> + </tr> + <tr> + <td>{@link android.content.AsyncTaskLoader}</td> + <td>Abstract loader that provides an {@link android.os.AsyncTask} to do the work.</td> + </tr> + <tr> + <td>{@link android.content.CursorLoader}</td> + <td>A subclass of {@link android.content.AsyncTaskLoader} that queries the +{@link android.content.ContentResolver} and returns a {@link +android.database.Cursor}. This class implements the {@link +android.content.Loader} protocol in a standard way for querying cursors, +building on {@link android.content.AsyncTaskLoader} to perform the cursor query +on a background thread so that it does not block the application's UI. Using +this loader is the best way to asynchronously load data from a {@link +android.content.ContentProvider}, instead of performing a managed query through +the fragment or activity's APIs.</td> + </tr> +</table> + +<p>The classes and interfaces in the above table are the essential components +you'll use to implement a loader in your application. You won't need all of them +for each loader you create, but you'll always need a reference to the {@link +android.app.LoaderManager} in order to initialize a loader and an implementation +of a {@link android.content.Loader} class such as {@link +android.content.CursorLoader}. The following sections show you how to use these +classes and interfaces in an application.</p> + +<h2 id ="app">Using Loaders in an Application</h2> +<p>This section describes how to use loaders in an Android application. An +application that uses loaders typically includes the following:</p> +<ul> + <li>An {@link android.app.Activity} or {@link android.app.Fragment}.</li> + <li>An instance of the {@link android.app.LoaderManager}.</li> + <li>A {@link android.content.CursorLoader} to load data backed by a {@link +android.content.ContentProvider}. Alternatively, you can implement your own subclass +of {@link android.content.Loader} or {@link android.content.AsyncTaskLoader} to +load data from some other source.</li> + <li>An implementation for {@link android.app.LoaderManager.LoaderCallbacks}. +This is where you create new loaders and manage your references to existing +loaders.</li> +<li>A way of displaying the loader's data, such as a {@link +android.widget.SimpleCursorAdapter}.</li> + <li>A data source, such as a {@link android.content.ContentProvider}, when using a +{@link android.content.CursorLoader}.</li> +</ul> +<h3 id="starting">Starting a Loader</h3> + +<p>The {@link android.app.LoaderManager} manages one or more {@link +android.content.Loader} instances within an {@link android.app.Activity} or +{@link android.app.Fragment}. There is only one {@link +android.app.LoaderManager} per activity or fragment.</p> + +<p>You typically +initialize a {@link android.content.Loader} within the activity's {@link +android.app.Activity#onCreate onCreate()} method, or within the fragment's +{@link android.app.Fragment#onActivityCreated onActivityCreated()} method. You +do this as follows:</p> + +<pre>// Prepare the loader. Either re-connect with an existing one, +// or start a new one. +getLoaderManager().initLoader(0, null, this);</pre> + +<p>The {@link android.app.LoaderManager#initLoader initLoader()} method takes +the following parameters:</p> +<ul> + <li>A unique ID that identifies the loader. In this example, the ID is 0.</li> +<li>Optional arguments to supply to the loader at +construction (<code>null</code> in this example).</li> + +<li>A {@link android.app.LoaderManager.LoaderCallbacks} implementation, which +the {@link android.app.LoaderManager} calls to report loader events. In this +example, the local class implements the {@link +android.app.LoaderManager.LoaderCallbacks} interface, so it passes a reference +to itself, {@code this}.</li> +</ul> +<p>The {@link android.app.LoaderManager#initLoader initLoader()} call ensures that a loader +is initialized and active. It has two possible outcomes:</p> +<ul> + <li>If the loader specified by the ID already exists, the last created loader +is reused.</li> + <li>If the loader specified by the ID does <em>not</em> exist, +{@link android.app.LoaderManager#initLoader initLoader()} triggers the +{@link android.app.LoaderManager.LoaderCallbacks} method {@link android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()}. +This is where you implement the code to instantiate and return a new loader. +For more discussion, see the section <a +href="#onCreateLoader">onCreateLoader</a>.</li> +</ul> +<p>In either case, the given {@link android.app.LoaderManager.LoaderCallbacks} +implementation is associated with the loader, and will be called when the +loader state changes. If at the point of this call the caller is in its +started state, and the requested loader already exists and has generated its +data, then the system calls {@link +android.app.LoaderManager.LoaderCallbacks#onLoadFinished onLoadFinished()} +immediately (during {@link android.app.LoaderManager#initLoader initLoader()}), +so you must be prepared for this to happen. See <a href="#onLoadFinished"> +onLoadFinished</a> for more discussion of this callback</p> + +<p>Note that the {@link android.app.LoaderManager#initLoader initLoader()} +method returns the {@link android.content.Loader} that is created, but you don't +need to capture a reference to it. The {@link android.app.LoaderManager} manages +the life of the loader automatically. The {@link android.app.LoaderManager} +starts and stops loading when necessary, and maintains the state of the loader +and its associated content. As this implies, you rarely interact with loaders +directly (though for an example of using loader methods to fine-tune a loader's +behavior, see the <a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.html"> LoaderThrottle</a> sample). +You most commonly use the {@link +android.app.LoaderManager.LoaderCallbacks} methods to intervene in the loading +process when particular events occur. For more discussion of this topic, see <a +href="#callback">Using the LoaderManager Callbacks</a>.</p> + +<h3 id="restarting">Restarting a Loader</h3> + +<p>When you use {@link android.app.LoaderManager#initLoader initLoader()}, as +shown above, it uses an existing loader with the specified ID if there is one. +If there isn't, it creates one. But sometimes you want to discard your old data +and start over.</p> + +<p>To discard your old data, you use {@link +android.app.LoaderManager#restartLoader restartLoader()}. For example, this +implementation of {@link android.widget.SearchView.OnQueryTextListener} restarts +the loader when the user's query changes. The loader needs to be restarted so +that it can use the revised search filter to do a new query:</p> + +<pre> +public boolean onQueryTextChanged(String newText) { + // Called when the action bar search text has changed. Update + // the search filter, and restart the loader to do a new query + // with this filter. + mCurFilter = !TextUtils.isEmpty(newText) ? newText : null; + getLoaderManager().restartLoader(0, null, this); + return true; +}</pre> + +<h3 id="callback">Using the LoaderManager Callbacks</h3> + +<p>{@link android.app.LoaderManager.LoaderCallbacks} is a callback interface +that lets a client interact with the {@link android.app.LoaderManager}. </p> +<p>Loaders, in particular {@link android.content.CursorLoader}, are expected to +retain their data after being stopped. This allows applications to keep their +data across the activity or fragment's {@link android.app.Activity#onStop +onStop()} and {@link android.app.Activity#onStart onStart()} methods, so that +when users return to an application, they don't have to wait for the data to +reload. You use the {@link android.app.LoaderManager.LoaderCallbacks} methods +when to know when to create a new loader, and to tell the application when it is + time to stop using a loader's data.</p> + +<p>{@link android.app.LoaderManager.LoaderCallbacks} includes these +methods:</p> +<ul> + <li>{@link android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()} — +Instantiate and return a new {@link android.content.Loader} for the given ID. +</li></ul> +<ul> + <li> {@link android.app.LoaderManager.LoaderCallbacks#onLoadFinished onLoadFinished()} +— Called when a previously created loader has finished its load. +</li></ul> +<ul> + <li>{@link android.app.LoaderManager.LoaderCallbacks#onLoaderReset onLoaderReset()} + — Called when a previously created loader is being reset, thus making its +data unavailable. +</li> +</ul> +<p>These methods are described in more detail in the following sections.</p> + +<h4 id ="onCreateLoader">onCreateLoader</h4> + +<p>When you attempt to access a loader (for example, through {@link +android.app.LoaderManager#initLoader initLoader()}), it checks to see whether +the loader specified by the ID exists. If it doesn't, it triggers the {@link +android.app.LoaderManager.LoaderCallbacks} method {@link +android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()}. This +is where you create a new loader. Typically this will be a {@link +android.content.CursorLoader}, but you can implement your own {@link +android.content.Loader} subclass. </p> + +<p>In this example, the {@link +android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()} +callback method creates a {@link android.content.CursorLoader}. You must build +the {@link android.content.CursorLoader} using its constructor method, which +requires the complete set of information needed to perform a query to the {@link +android.content.ContentProvider}. Specifically, it needs:</p> +<ul> + <li><em>uri</em> — The URI for the content to retrieve. </li> + <li><em>projection</em> — A list of which columns to return. Passing +<code>null</code> will return all columns, which is inefficient. </li> + <li><em>selection</em> — A filter declaring which rows to return, +formatted as an SQL WHERE clause (excluding the WHERE itself). Passing +<code>null</code> will return all rows for the given URI. </li> + <li><em>selectionArgs</em> — You may include ?s in the selection, which will +be replaced by the values from <em>selectionArgs</em>, in the order that they appear in +the selection. The values will be bound as Strings. </li> + <li><em>sortOrder</em> — How to order the rows, formatted as an SQL +ORDER BY clause (excluding the ORDER BY itself). Passing <code>null</code> will +use the default sort order, which may be unordered.</li> +</ul> +<p>For example:</p> +<pre> + // If non-null, this is the current filter the user has provided. +String mCurFilter; +... +public Loader<Cursor> onCreateLoader(int id, Bundle args) { + // This is called when a new Loader needs to be created.  This + // sample only has one Loader, so we don't care about the ID. + // First, pick the base URI to use depending on whether we are + // currently filtering. + Uri baseUri; +  if (mCurFilter != null) { +    baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, +        Uri.encode(mCurFilter)); +  } else { +    baseUri = Contacts.CONTENT_URI; +  } + +  // Now create and return a CursorLoader that will take care of +  // creating a Cursor for the data being displayed. +  String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND (" +      + Contacts.HAS_PHONE_NUMBER + "=1) AND (" +      + Contacts.DISPLAY_NAME + " != '' ))"; +  return new CursorLoader(getActivity(), baseUri, +      CONTACTS_SUMMARY_PROJECTION, select, null, +      Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); +}</pre> +<h4 id="onLoadFinished">onLoadFinished</h4> + +<p>This method is called when a previously created loader has finished its load. +This method is guaranteed to be called prior to the release of the last data +that was supplied for this loader. At this point you should remove all use of +the old data (since it will be released soon), but should not do your own +release of the data since its loader owns it and will take care of that.</p> + + +<p>The loader will release the data once it knows the application is no longer +using it. For example, if the data is a cursor from a {@link +android.content.CursorLoader}, you should not call {@link +android.database.Cursor#close close()} on it yourself. If the cursor is being +placed in a {@link android.widget.CursorAdapter}, you should use the {@link +android.widget.SimpleCursorAdapter#swapCursor swapCursor()} method so that the +old {@link android.database.Cursor} is not closed. For example:</p> + +<pre> +// This is the Adapter being used to display the list's data.<br +/>SimpleCursorAdapter mAdapter; +... + +public void onLoadFinished(Loader<Cursor> loader, Cursor data) { + // Swap the new cursor in.  (The framework will take care of closing the + // old cursor once we return.) + mAdapter.swapCursor(data); +}</pre> + +<h4 id="onLoaderReset">onLoaderReset</h4> + +<p>This method is called when a previously created loader is being reset, thus +making its data unavailable. This callback lets you find out when the data is +about to be released so you can remove your reference to it.  </p> +<p>This implementation calls +{@link android.widget.SimpleCursorAdapter#swapCursor swapCursor()} +with a value of <code>null</code>:</p> + +<pre> +// This is the Adapter being used to display the list's data. +SimpleCursorAdapter mAdapter; +... + +public void onLoaderReset(Loader<Cursor> loader) { + // This is called when the last Cursor provided to onLoadFinished() + // above is about to be closed.  We need to make sure we are no + // longer using it. + mAdapter.swapCursor(null); +}</pre> + + +<h2 id="example">Example</h2> + +<p>As an example, here is the full implementation of a {@link +android.app.Fragment} that displays a {@link android.widget.ListView} containing +the results of a query against the contacts content provider. It uses a {@link +android.content.CursorLoader} to manage the query on the provider.</p> + +<p>For an application to access a user's contacts, as shown in this example, its +manifest must include the permission +{@link android.Manifest.permission#READ_CONTACTS READ_CONTACTS}.</p> + +<pre> +public static class CursorLoaderListFragment extends ListFragment +    implements OnQueryTextListener, LoaderManager.LoaderCallbacks<Cursor> { + + // This is the Adapter being used to display the list's data. +  SimpleCursorAdapter mAdapter; + +  // If non-null, this is the current filter the user has provided. +  String mCurFilter; + +  @Override public void onActivityCreated(Bundle savedInstanceState) { +    super.onActivityCreated(savedInstanceState); + +    // Give some text to display if there is no data.  In a real +    // application this would come from a resource. +    setEmptyText("No phone numbers"); + +    // We have a menu item to show in action bar. +    setHasOptionsMenu(true); + +    // Create an empty adapter we will use to display the loaded data. +    mAdapter = new SimpleCursorAdapter(getActivity(), +        android.R.layout.simple_list_item_2, null, +        new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS }, +        new int[] { android.R.id.text1, android.R.id.text2 }, 0); +    setListAdapter(mAdapter); + +    // Prepare the loader.  Either re-connect with an existing one, +    // or start a new one. +    getLoaderManager().initLoader(0, null, this); +  } + +  @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { +    // Place an action bar item for searching. +    MenuItem item = menu.add("Search"); +    item.setIcon(android.R.drawable.ic_menu_search); +    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); +    SearchView sv = new SearchView(getActivity()); +    sv.setOnQueryTextListener(this); +    item.setActionView(sv); +  } + +  public boolean onQueryTextChange(String newText) { +    // Called when the action bar search text has changed.  Update +    // the search filter, and restart the loader to do a new query +    // with this filter. +    mCurFilter = !TextUtils.isEmpty(newText) ? newText : null; +    getLoaderManager().restartLoader(0, null, this); +    return true; +  } + +  @Override public boolean onQueryTextSubmit(String query) { +    // Don't care about this. +    return true; +  } + +  @Override public void onListItemClick(ListView l, View v, int position, long id) { +    // Insert desired behavior here. +    Log.i("FragmentComplexList", "Item clicked: " + id); +  } + +  // These are the Contacts rows that we will retrieve. +  static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { +    Contacts._ID, +    Contacts.DISPLAY_NAME, +    Contacts.CONTACT_STATUS, +    Contacts.CONTACT_PRESENCE, +    Contacts.PHOTO_ID, +    Contacts.LOOKUP_KEY, +  }; +  public Loader<Cursor> onCreateLoader(int id, Bundle args) { +    // This is called when a new Loader needs to be created.  This +    // sample only has one Loader, so we don't care about the ID. +    // First, pick the base URI to use depending on whether we are +    // currently filtering. +    Uri baseUri; +    if (mCurFilter != null) { +      baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, +          Uri.encode(mCurFilter)); +    } else { +      baseUri = Contacts.CONTENT_URI; +    } + +    // Now create and return a CursorLoader that will take care of +    // creating a Cursor for the data being displayed. +    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND (" +        + Contacts.HAS_PHONE_NUMBER + "=1) AND (" +        + Contacts.DISPLAY_NAME + " != '' ))"; +    return new CursorLoader(getActivity(), baseUri, +        CONTACTS_SUMMARY_PROJECTION, select, null, +        Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); +  } + +  public void onLoadFinished(Loader<Cursor> loader, Cursor data) { +    // Swap the new cursor in.  (The framework will take care of closing the +    // old cursor once we return.) +    mAdapter.swapCursor(data); +  } + +  public void onLoaderReset(Loader<Cursor> loader) { +    // This is called when the last Cursor provided to onLoadFinished() +    // above is about to be closed.  We need to make sure we are no +    // longer using it. +    mAdapter.swapCursor(null); +  } +}</pre> +<h3 id="more_examples">More Examples</h3> + +<p>There are a few different samples in <strong>ApiDemos</strong> that +illustrate how to use loaders:</p> +<ul> + <li><a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/FragmentCursorLoader.html"> FragmentCursorLoader</a> — A complete version of the +snippet shown above.</li> + <li><a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.html"> LoaderThrottle</a> — An example of how to use throttling to +reduce the number of queries a content provider does then its data changes.</li> +</ul> + +<p>For information on downloading and installing the SDK samples, see <a +href="http://developer.android.com/resources/samples/get.html"> Getting the +Samples</a>. </p> + diff --git a/docs/html/guide/topics/ui/drag-drop.jd b/docs/html/guide/topics/ui/drag-drop.jd index 588b05b..46ccdf8 100644 --- a/docs/html/guide/topics/ui/drag-drop.jd +++ b/docs/html/guide/topics/ui/drag-drop.jd @@ -88,8 +88,8 @@ page.title=Dragging and Dropping <h2>Related Samples</h2> <ol> <li> - <a href="{@docRoot}resources/samples/Honeycomb-Gallery/index.html"> - Honeycomb-Gallery</a> sample application. + <a href="{@docRoot}resources/samples/HoneycombGallery/index.html"> + Honeycomb Gallery</a>. </li> <li> <a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/DragAndDropDemo.html"> diff --git a/docs/html/sdk/android-2.3.3.jd b/docs/html/sdk/android-2.3.3.jd index dbc48f4..6d60fcc 100644 --- a/docs/html/sdk/android-2.3.3.jd +++ b/docs/html/sdk/android-2.3.3.jd @@ -54,7 +54,7 @@ href="{@docRoot}sdk/index.html">download the SDK Starter Package</a> first.</p> <p>For a high-level introduction to Android 2.3, see the <a -href="http://developer.android.com/sdk/android-2.3-highlights.html">Platform Highlights</a>.</p> +href="{@docRoot}sdk/android-2.3-highlights.html">Platform Highlights</a>.</p> <h2 id="relnotes">Revisions</h2> diff --git a/docs/html/sdk/android-2.3.jd b/docs/html/sdk/android-2.3.jd index 734d97b..e7aa0fa 100644 --- a/docs/html/sdk/android-2.3.jd +++ b/docs/html/sdk/android-2.3.jd @@ -51,7 +51,7 @@ href="{@docRoot}sdk/index.html">download the SDK Starter Package</a> first.</p> <p>For a high-level introduction to Android {@sdkPlatformVersion}, see the <a -href="http://developer.android.com/sdk/android-{@sdkPlatformVersion}-highlights.html">Platform Highlights</a>.</p> +href="{@docRoot}sdk/android-{@sdkPlatformVersion}-highlights.html">Platform Highlights</a>.</p> <h2 id="relnotes">Revisions</h2> diff --git a/docs/html/sdk/android-3.0.jd b/docs/html/sdk/android-3.0.jd index 2c8a7f0..6842c82 100644 --- a/docs/html/sdk/android-3.0.jd +++ b/docs/html/sdk/android-3.0.jd @@ -1,4 +1,6 @@ page.title=Android 3.0 Platform Preview +sdk.platform.version=3.0 +sdk.platform.apiLevel=11 @jd:body <div id="qv-wrapper"> @@ -6,6 +8,7 @@ page.title=Android 3.0 Platform Preview <h2>In this document</h2> <ol> + <li><a href="#relnotes">Revisions</a></li> <li><a href="#api">API Overview</a></li> <li><a href="#api-level">API Level</a></li> <li><a href="#apps">Built-in Applications</a></li> @@ -16,7 +19,7 @@ page.title=Android 3.0 Platform Preview <h2>Reference</h2> <ol> <li><a -href="{@docRoot}sdk/api_diff/honeycomb/changes.html">API +href="{@docRoot}sdk/api_diff/11/changes.html">API Differences Report »</a> </li> </ol> @@ -28,19 +31,52 @@ Differences Report »</a> </li> </div> </div> -<p><em>API Level:</em> <b>Honeycomb</b></p> -<p>For developers, the Android 3.0 preview is available as a downloadable component for the -Android SDK.</p> +<p><em>API Level:</em> <strong>{@sdkPlatformApiLevel}</strong></p> -<p class="note"><strong>Note:</strong> Read the <a -href="{@docRoot}sdk/preview/start.html">Getting Started</a> guide for important information -about setting up your development environment and limitiations of the Android 3.0 preview.</p> +<p>For developers, the Android {@sdkPlatformVersion} platform is available as a downloadable +component for the Android SDK. The downloadable platform includes an Android library and system +image, as well as a set of emulator skins and more. The downloadable platform includes no external +libraries.</p> +<p>To get started developing or testing against Android {@sdkPlatformVersion}, use the Android SDK +Manager to download the platform into your SDK. For more information, see <a +href="{@docRoot}sdk/adding-components.html">Adding SDK Components</a>. If you are new to Android, <a +href="{@docRoot}sdk/index.html">download the SDK Starter Package</a> first.</p> +<p>For a high-level introduction to Android {@sdkPlatformVersion}, see the <a +href="{@docRoot}sdk/android-{@sdkPlatformVersion}-highlights.html">Platform +Highlights</a>.</p> +<h2 id="relnotes">Revisions</h2> + +<p>To determine what revision of the Android {@sdkPlatformVersion} platform you have installed, +refer to the "Installed Packages" listing in the Android SDK and AVD Manager.</p> + + +<div class="toggle-content opened" style="padding-left:1em;"> + + <p><a href="#" onclick="return toggleContent(this)"> + <img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-content-img" alt="" /> + Android {@sdkPlatformVersion}, Revision 1</a> <em>(February 2011)</em> + </a></p> + + <div class="toggle-content-toggleme" style="padding-left:2em;"> + +<dl> + +<dt>Dependencies:</dt> +<dd> +<p>Requires <a href="{@docRoot}sdk/tools-notes.html">SDK Tools r10</a> or higher.</p> +</dd> + +</dl> + + </div> +</div> + <h2 id="#api">API Overview</h2> @@ -49,6 +85,9 @@ about setting up your development environment and limitiations of the Android 3. including new features and changes in the framework API since the previous version.</p> + + + <h3>Fragments</h3> <p>A fragment is a new framework component that allows you to separate distinct elements of an @@ -65,9 +104,9 @@ activity is running.</p> <p>Additionally:</p> <ul> - <li>Fragments are self-contained and can be reused in multiple activities</li> - <li>Fragments can be added, removed, replaced and animated inside the activity</li> - <li>Fragment can be added to a back stack managed by the activity, preserving the state of + <li>Fragments are self-contained and you can reuse them in multiple activities</li> + <li>You can add, remove, replace and animate fragments inside the activity</li> + <li>You can add fragments to a back stack managed by the activity, preserving the state of fragments as they are changed and allowing the user to navigate backward through the different states</li> <li>By <a @@ -80,8 +119,8 @@ activity's Action Bar (discussed next)</li> <p>To manage the fragments in your activity, you must use the {@link android.app.FragmentManager}, which provides several APIs for interacting with fragments, such -as finding fragments in the activity and popping fragments off the back stack to restore them -after they've been removed or hidden.</p> +as finding fragments in the activity and popping fragments off the back stack to restore their +previous state.</p> <p>To perform a transaction, such as add or remove a fragment, you must create a {@link android.app.FragmentTransaction}. You can then call methods such as {@link @@ -92,7 +131,10 @@ android.app.FragmentTransaction#commit commit()} and the system applies the frag the activity.</p> <p>For more information about using fragments, read the <a -href="{@docRoot}guide/topics/fundamentals/fragments.html">Fragments</a> developer guide.</p> +href="{@docRoot}guide/topics/fundamentals/fragments.html">Fragments</a> documentation. Several +samples are also available in the <a +href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/index.html#Fragment"> +API Demos</a> application.</p> @@ -101,49 +143,51 @@ href="{@docRoot}guide/topics/fundamentals/fragments.html">Fragments</a> develope <p>The Action Bar is a replacement for the traditional title bar at the top of the activity window. It includes the application logo in the left corner and provides a new interface for items in the -activity's Options Menu. Additionally, the Action Bar allows you to:</p> +<a href="{@docRoot}guide/topics/ui/menus.html#options-menu">Options Menu</a>. Additionally, the +Action Bar allows you to:</p> <ul> - <li>Include select menu items directly in the Action Bar—as "action -items"—for quick access to global user actions. - <p>In your XML declaration for the menu item, include the attribute, {@code -android:showAsAction} with a value of {@code "ifRoom"}. When there's enough room in the -Action Bar, the menu item appears directly in the bar. Otherwise, the item is placed in the -overflow menu, revealed by the icon on the right side of the Action Bar.</p></li> - - <li>Add interactive widgets to the Action Bar—as "action views"—such as a search box. - <p>In the XML for the menu item that should behave as an action view, include the {@code -android:actionViewLayout} attribute with a layout -resource for the action view or {@code android:actionViewClass} with the class name of the -widget. Like action items, an action view appears only when there's room for it in the Action -Bar. If there's not enough room, it is placed in the overflow menu and behaves like a regular -menu item (for example, an item can provide a {@link android.widget.SearchView} as an action -view, but when in the overflow menu, selecting the item activates the search dialog).</p></li> - - <li>Add an action to the application logo when tapped and replace it with a custom logo + <li>Add menu items directly in the Action Bar—as "action items." + <p>In your XML declaration for the menu item, include the {@code +android:showAsAction} attribute with a value of {@code "ifRoom"}. When there's enough room, the menu +item appears directly in the Action Bar. Otherwise, the item is placed in the +overflow menu, revealed by the menu icon on the right side of the Action Bar.</p></li> + + <li>Replace an action item with a widget (such as a search box)—creating an +"action view." + <p>In the XML declaration for the menu item, add the {@code android:actionViewLayout} attribute +with a layout resource or the {@code android:actionViewClass} attribute with the class name of a +widget. (You must also declare the {@code android:showAsAction} attribute so that the item appears +in the Action Bar.) If there's not enough room in the Action Bar and the item appears in the +overflow menu, it behaves like a regular menu item and does not show the widget.</p></li> + + <li>Add an action to the application logo and replace it with a custom logo <p>The application logo is automatically assigned the {@code android.R.id.home} ID, -which the system deliveres to your activity's {@link android.app.Activity#onOptionsItemSelected -onOptionsItemSelected()} callback when tapped. Simply respond to this ID in your callback +which the system delivers to your activity's {@link android.app.Activity#onOptionsItemSelected +onOptionsItemSelected()} callback when touched. Simply respond to this ID in your callback method to perform an action such as go to your application's "home" activity.</p> - <p>To replace the icon with a logo, </p></li> - - <li>Add breadcrumbs for navigating backward through fragments</li> - <li>Add built in tabs and a drop-down list for navigation</li> - <li>Customize the Action Bar themes and custom backgrounds</li> + <p>To replace the icon with a logo, specify your application logo in the manifest file with the +<a href="{@docRoot}guide/topics/manifest/application-element.html#logo">{@code android:logo}</a> +attribute, then call {@link android.app.ActionBar#setDisplayUseLogoEnabled +setDisplayUseLogoEnabled(true)} in your activity.</p></li> + + <li>Add breadcrumbs to navigate backward through the back stack of fragments</li> + <li>Add tabs or a drop-down list to navigate through fragments</li> + <li>Customize the Action Bar with themes and backgrounds</li> </ul> -<p>The Action Bar is standard for all applications that set either the <a +<p>The Action Bar is standard for all applications that use the new holographic theme, which is +also standard when you set either the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a> or <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code -android:targetSdkVersion}</a> to {@code "Honeycomb"}. (The "Honeycomb" API Level is provisional -and effective only while using the preview SDK—you must change it to the official API -Level when the final SDK becomes available—see <a -href="{@docRoot}sdk/preview/start.html">Getting Started</a> for more information.)</p> +android:targetSdkVersion}</a> to {@code "11"}.</p> <p>For more information about the Action Bar, read the <a -href="{@docRoot}guide/topics/ui/actionbar.html">Action -Bar</a> developer guide.</p> +href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> documentation. Several +samples are also available in the <a +href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/index.html#ActionBar"> +API Demos</a> application.</p> @@ -153,97 +197,123 @@ Bar</a> developer guide.</p> <p>Applications can now copy and paste data (beyond mere text) to and from the system-wide clipboard. Clipped data can be plain text, a URI, or an intent.</p> -<p>By providing the system access to your data in a content provider, the user can copy complex -content (such as an image or data structure) from your application and paste it into another -application that supports that type of content.</p> +<p>By providing the system access to the data you want the user to copy, through a content provider, +the user can copy complex content (such as an image or data structure) from your application and +paste it into another application that supports that type of content.</p> <p>To start using the clipboard, get the global {@link android.content.ClipboardManager} object by calling {@link android.content.Context#getSystemService getSystemService(CLIPBOARD_SERVICE)}.</p> -<p>To create an item to attach to the clipboard ("copy"), you need to create a new {@link +<p>To copy an item to the clipboard, you need to create a new {@link android.content.ClipData} object, which holds one or more {@link android.content.ClipData.Item} -objects, each describing a single entity. To create a {@link android.content.ClipData} object with -just one {@link android.content.ClipData.Item}, you can use one of the helper methods, such as -{@link android.content.ClipData#newPlainText newPlainText()}, {@link +objects, each describing a single entity. To create a {@link android.content.ClipData} object +containing just one {@link android.content.ClipData.Item}, you can use one of the helper methods, +such as {@link android.content.ClipData#newPlainText newPlainText()}, {@link android.content.ClipData#newUri newUri()}, and {@link android.content.ClipData#newIntent newIntent()}, which each return a {@link android.content.ClipData} object pre-loaded with the -appropriate {@link android.content.ClipData.Item}.</p> +{@link android.content.ClipData.Item} you provide.</p> <p>To add the {@link android.content.ClipData} to the clipboard, pass it to {@link android.content.ClipboardManager#setPrimaryClip setPrimaryClip()} for your instance of {@link android.content.ClipboardManager}.</p> -<p>You can then acquire ("paste") a file from the clipboard by calling {@link +<p>You can then read a file from the clipboard (in order to paste it) by calling {@link android.content.ClipboardManager#getPrimaryClip()} on the {@link android.content.ClipboardManager}. Handling the {@link android.content.ClipData} you receive can -be more complicated and you need to be sure you can actually handle the data type.</p> +be complicated and you need to be sure you can actually handle the data type in the clipboard +before attempting to paste it.</p> -<p>For more information, see the {@link android.content.ClipData} class reference. You can also see -an example implementation of copy and paste in the <a -href="{@docRoot}resources/samples/NotePad/index.html">NotePad</a> sample application.</p> +<p>The clipboard holds only one piece of clipped data (a {@link android.content.ClipData} +object) at a time, but one {@link android.content.ClipData} can contain multiple {@link +android.content.ClipData.Item}s.</p> + +<p>For more information, read the <a href="{@docRoot}guide/topics/clipboard/copy-paste.html">Copy +and Paste</a> documentation. You can also see a simple implementation of copy and paste in the <a +href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/content/ClipboardSample. +html">API Demos</a> and a more complete implementation in the <a +href="{@docRoot}resources/samples/NotePad/index.html">Note Pad</a> application.</p> <h3>Drag and drop</h3> -<p>New APIs facilitate the ability for your application to implement drag and drop -functionality in the UI.</p> +<p>New APIs simplify drag and drop operations in your application's user interface. A drag +operation is the transfer of some kind of data—carried in a {@link android.content.ClipData} +object—from one place to another. The start and end point for the drag operation is a {@link +android.view.View}, so the APIs that directly handle the drag and drop operations are +in the {@link android.view.View} class.</p> + +<p>A drag and drop operation has a lifecycle that's defined by several drag actions—each +defined by a {@link android.view.DragEvent} object—such as {@link +android.view.DragEvent#ACTION_DRAG_STARTED}, {@link android.view.DragEvent#ACTION_DRAG_ENTERED}, and +{@link android.view.DragEvent#ACTION_DROP}. Each view that wants to participate in a drag +operation can listen for these actions.</p> <p>To begin dragging content in your activity, call {@link android.view.View#startDrag startDrag()} on a {@link android.view.View}, providing a {@link android.content.ClipData} object that represents -the information to drag, a {@link android.view.View.DragShadowBuilder} to facilitate the "shadow" -that the user sees while dragging, and an {@link java.lang.Object} that can share information about -the drag object with views that may receive the object.</p> - -<p>To accept a drag object (receive the "drop") in a -{@link android.view.View}, register the view with an {@link android.view.View.OnDragListener -OnDragListener} by -calling {@link android.view.View#setOnDragListener setOnDragListener()}. When a drag event occurs on -the view, the system calls {@link android.view.View.OnDragListener#onDrag onDrag()} for the {@link +the data to drag, a {@link android.view.View.DragShadowBuilder} to facilitate the "shadow" +that users see under their fingers while dragging, and an {@link java.lang.Object} that can share +information about the drag object with views that may receive the object.</p> + +<p>To accept a drag object in a {@link android.view.View} (receive the "drop"), register the view +with an {@link android.view.View.OnDragListener OnDragListener} by calling {@link +android.view.View#setOnDragListener setOnDragListener()}. When a drag event occurs on the view, the +system calls {@link android.view.View.OnDragListener#onDrag onDrag()} for the {@link android.view.View.OnDragListener OnDragListener}, which receives a {@link android.view.DragEvent} -describing the -type of event has occurred (such as "drag started", "drag ended", or "drop"). During a drag, the -system repeatedly calls {@link -android.view.View.OnDragListener#onDrag onDrag()} for the view underneath the drag, to -deliver a stream of events. The receiving view can -inquire the event type delivered to {@link android.view.View#onDragEvent onDragEvent()} by calling -{@link android.view.DragEvent#getAction getAction()} on the {@link android.view.DragEvent}.</p> +describing the type of drag action has occurred (such as {@link +android.view.DragEvent#ACTION_DRAG_STARTED}, {@link android.view.DragEvent#ACTION_DRAG_ENTERED}, and +{@link android.view.DragEvent#ACTION_DROP}). During a drag, the system repeatedly calls {@link +android.view.View.OnDragListener#onDrag onDrag()} for the view underneath the drag, to deliver a +stream of drag events. The receiving view can inquire the event type delivered to {@link +android.view.View#onDragEvent onDragEvent()} by calling {@link android.view.DragEvent#getAction +getAction()} on the {@link android.view.DragEvent}.</p> -<p>Although a drag event may carry a {@link android.content.ClipData} object, this is not related -to the system clipboard. The data being dragged is passed as a {@link -android.content.ClipData} object to {@link android.view.View#startDrag startDrag()} and the system -sends it to the receiving {@link android.view.View} in the {@link android.view.DragEvent} sent to -{@link android.view.View.OnDragListener#onDrag onDrag()}. A drag and drop operation should never -put the dragged data in the global system clipboard.</p> +<p class="note"><strong>Note:</strong> Although a drag event may carry a {@link +android.content.ClipData} object, this is not related to the system clipboard. A drag and drop +operation should never put the dragged data in the system clipboard.</p> + +<p>For more information, read the <a href="{@docRoot}guide/topics/ui/drag-drop.html">Dragging and +Dropping</a> documentation. You can also see an implementation of drag and drop in the <a +href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/DragAndDropDemo.html"> +API Demos</a> application and the <a +href="{@docRoot}resources/samples/HoneycombGallery/index.html">Honeycomb Gallery</a> +application.</p> <h3>App widgets</h3> -<p>Android 3.0 supports several new widget classes for more interactive app widgets, including: -{@link -android.widget.GridView}, {@link android.widget.ListView}, {@link android.widget.StackView}, {@link -android.widget.ViewFlipper}, and {@link android.widget.AdapterViewFlipper}.</p> +<p>Android 3.0 supports several new widget classes for more interactive app widgets on the users +Home screen, including: {@link android.widget.GridView}, {@link android.widget.ListView}, {@link +android.widget.StackView}, {@link android.widget.ViewFlipper}, and {@link +android.widget.AdapterViewFlipper}.</p> -<p>You can also use the new {@link android.widget.RemoteViewsService} to populate -collection views such as ({@link android.widget.GridView}, {@link android.widget.ListView}, and -{@link android.widget.StackView}).</p> +<p>More importantly, you can use the new {@link android.widget.RemoteViewsService} to create app +widgets with collections, using widgets such as {@link android.widget.GridView}, {@link +android.widget.ListView}, and {@link android.widget.StackView} that are backed by remote data, +such as from a content provider.</p> -<p>{@link android.appwidget.AppWidgetProviderInfo} also supports two new fields: {@link +<p>The {@link android.appwidget.AppWidgetProviderInfo} class (defined with an {@code +<appwidget-provider> XML file) also supports two new fields: {@link android.appwidget.AppWidgetProviderInfo#autoAdvanceViewId} and {@link android.appwidget.AppWidgetProviderInfo#previewImage}. The {@link android.appwidget.AppWidgetProviderInfo#autoAdvanceViewId} field lets you specify the view ID of the -app widget subview, which is auto-advanced by the app widget’s host. The +app widget subview that should be auto-advanced by the app widget’s host. The {@link android.appwidget.AppWidgetProviderInfo#previewImage} field specifies a preview of what the app widget looks like and is shown to the user from the widget picker. If this field is not supplied, the app widget's icon is used for the preview.</p> -<p>Android also provides a new widget preview tool ({@code WidgetPreview}), located in the SDK -tools, to take a screenshot of your app widget, which you can use when specifying the {@link -android.appwidget.AppWidgetProviderInfo#previewImage} field.</p> - +<p>To help create a preview image for your app widget (to specify in the {@link +android.appwidget.AppWidgetProviderInfo#autoAdvanceViewId} field), the Android emulator includes an +application called "Widget Preview." To create a preview image, launch this application, select the +app widget for your application and set it up how you'd like your preview image to appear, then save +it and place it in your application's drawable resources.</p> +<p>You can see an implementation of the new app widget features in the <a +href="{@docRoot}resources/samples/StackWidget/index.html">StackView App Widget</a> and <a +href="{@docRoot}resources/samples/WeatherListWidget/index.html">Weather List Widget</a> +applications.</p> @@ -251,7 +321,7 @@ android.appwidget.AppWidgetProviderInfo#previewImage} field.</p> <p>The {@link android.app.Notification} APIs have been extended to support more content-rich status bar notifications, plus a new {@link android.app.Notification.Builder} class allows you to easily -control the notification properties.</p> +create {@link android.app.Notification} objects.</p> <p>New features include:</p> <ul> <li>Support for a large icon in the notification, using {@link @@ -261,22 +331,32 @@ notification or for media apps to show an album thumbnail.</li> <li>Support for custom layouts in the status bar ticker, using {@link android.app.Notification.Builder#setTicker(CharSequence,RemoteViews) setTicker()}.</li> <li>Support for custom notification layouts to include buttons with {@link -android.app.PendingIntent}s, for more interactive notification widgets -(such as to control ongoing music in the background).</li> +android.app.PendingIntent}s, for more interactive notification widgets. For example, a +notification can control music playback without starting an activity.</li> </ul> - <h3>Content loaders</h3> <p>New framework APIs facilitate asynchronous loading of data using the {@link android.content.Loader} class. You can use it in combination with UI components such as views and fragments to dynamically load data from worker threads. The {@link -android.content.CursorLoader} subclass is specially designed to help do so for data queried from -a {@link android.content.ContentResolver}.</p> +android.content.CursorLoader} subclass is specially designed to help you do so for data backed by +a {@link android.content.ContentProvider}.</p> +<p>All you need to do is implement the {@link android.app.LoaderManager.LoaderCallbacks +LoaderCallbacks} interface to receive callbacks when a new loader is requested or the data has +changed, then call {@link android.app.LoaderManager#initLoader initLoader()} to initialize the +loader for your activity or fragment.</p> +<p>For more information, read the <a +href="{@docRoot}guide/topics/providers/loaders.html">Loaders</a> documentation. You can also see +example code using loaders in the <a +href="{@docRoot}samples/ApiDemos/src/com/example/android/apis/app/FragmentListCursorLoader.html"> +FragmentListCursorLoader</a> and <a +href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.html"> +LoaderThrottle</a> samples.</p> @@ -297,10 +377,10 @@ callbacks when the Bluetooth client is connected or disconnected.</p> -<h3>Animation framework</h3> +<h3 id="animation">Animation framework</h3> <p>An all new flexible animation framework allows you to animate arbitrary properties of any object -(View, Drawable, Fragment, Object, or anything else). It allows you to define many aspects of an +(View, Drawable, Fragment, Object, or anything else). It allows you to define several aspects of an animation, such as:</p> <ul> <li>Duration</li> @@ -309,13 +389,14 @@ animation, such as:</p> <li>Animator sets to play animations together, sequentially, or after specified delays</li> <li>Frame refresh delay</li> </ul> - + <p>You can define these animation aspects, and others, for an object's int, float, and hexadecimal -color values, by default. To animate any other type of value, you tell the system how to calculate -the values for that given type, by implementing the {@link android.animation.TypeEvaluator} -interface.</p> +color values, by default. That is, when an object has a property field for one of these types, you +can change its value over time to affect an animation. To animate any other type of value, you tell +the system how to calculate the values for that given type, by implementing the {@link +android.animation.TypeEvaluator} interface.</p> -<p>There are two animators you can use to animate values of a property: {@link +<p>There are two animators you can use to animate the values of a property: {@link android.animation.ValueAnimator} and {@link android.animation.ObjectAnimator}. The {@link android.animation.ValueAnimator} computes the animation values, but is not aware of the specific object or property that is animated as a result. It simply performs the calculations, and you must @@ -324,7 +405,7 @@ android.animation.ObjectAnimator} is a subclass of {@link android.animation.Valu allows you to set the object and property to animate, and it handles all animation work. That is, you give the {@link android.animation.ObjectAnimator} the object to animate, the property of the object to change over time, and a set of values to apply to the property over -time in order to animate it, then start the animation.</p> +time, then start the animation.</p> <p>Additionally, the {@link android.animation.LayoutTransition} class enables automatic transition animations for changes you make to your activity layout. To enable transitions for part of the @@ -338,7 +419,10 @@ such as a {@link android.animation.ValueAnimator} or {@link android.animation.Ob discussed above.</p> <p>For more information, see the <a -href="{@docRoot}guide/topics/graphics/animation.html">Animation</a> developer guide.</p> +href="{@docRoot}guide/topics/graphics/animation.html">Property Animation</a> documentation. You can +also see several samples using the animation APIs in the <a +href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/animation/index.html">API +Demos</a> application.</p> @@ -350,8 +434,11 @@ href="{@docRoot}guide/topics/graphics/animation.html">Animation</a> developer gu <li><b>Multiple-choice selection for ListView and GridView</b> <p>New {@link android.widget.AbsListView#CHOICE_MODE_MULTIPLE_MODAL} mode for {@link -android.widget.AbsListView#setChoiceMode setChoiceMode()} allows for selecting multiple items -from a {@link android.widget.ListView} and {@link android.widget.GridView}.</p> +android.widget.AbsListView#setChoiceMode setChoiceMode()} allows users to select multiple items +from a {@link android.widget.ListView} or {@link android.widget.GridView}. When used in +conjunction with the Action Bar, users can select multiple items and then select the action to +perform from a list of options in the Action Bar (which has transformed into a Multi-choice +Action Mode).</p> <p>To enable multiple-choice selection, call {@link android.widget.AbsListView#setChoiceMode setChoiceMode(CHOICE_MODE_MULTIPLE_MODAL)} and register a @@ -373,10 +460,11 @@ class in the API Demos sample application.</p> <li><b>New APIs to transform views</b> - <p>New APIs allow you to easily apply 2D and 3D transformations to {@link -android.view.View}s in your activity layout, using a set of object properties that define the view's + <p>New APIs allow you to easily apply 2D and 3D transformations to views in your activity +layout. New transformations are made possible with a set of object properties that define the view's layout position, orientation, transparency and more.</p> - <p>New methods to set properties include: {@link android.view.View#setAlpha setAlpha()}, {@link + <p>New methods to set the view properties include: {@link android.view.View#setAlpha +setAlpha()}, {@link android.view.View#setBottom setBottom()}, {@link android.view.View#setLeft setLeft()}, {@link android.view.View#setRight setRight()}, {@link android.view.View#setBottom setBottom()}, {@link android.view.View#setPivotX setPivotX()}, {@link android.view.View#setPivotY setPivotY()}, {@link @@ -385,14 +473,16 @@ setRotationY()}, {@link android.view.View#setScaleX setScaleX()}, {@link android setScaleY()}, {@link android.view.View#setAlpha setAlpha()}, and others.</p> <p>Some methods also have a corresponding XML attribute that you can specify in your layout -file. Available attributes include: {@code translationX}, {@code translationY}, {@code rotation}, +file, to apply a default transformation. Available attributes include: {@code translationX}, {@code +translationY}, {@code rotation}, {@code rotationX}, {@code rotationY}, {@code scaleX}, {@code scaleY}, {@code transformPivotX}, {@code transformPivotY}, and {@code alpha}.</p> - <p>Using some of these new properties in combination with the new animation framework (discussed -previously), you can easily create some fancy animations to your views. For example, to rotate a + <p>Using some of these new view properties in combination with the new <a +href="#animation">animation framework</a> (discussed +above), you can easily apply some fancy animations to your views. For example, to rotate a view on its y-axis, supply {@link android.animation.ObjectAnimator} with the {@link -android.view.View}, the "rotationY" property, and the values to use:</p> +android.view.View}, the "rotationY" property, and the start and end values:</p> <pre> ObjectAnimator animator = ObjectAnimator.ofFloat(myView, "rotationY", 0, 360); animator.setDuration(2000); @@ -403,16 +493,25 @@ animator.start(); <li><b>New holographic themes</b> - <p>The standard system widgets and overall look have been redesigned for use on larger screens -such as tablets and incorporate the new "holographic" UI theme. The system applies these styles -using the standard <a href="{@docRoot}guide/topics/ui/themes.html">style and theme</a> system. -Any application that targets the Android 3.0 platform inherits the holographic theme by default. -However, if your application also applies its own styles, then it will override the holographic -theme, unless you update your styles to inherit the holographic theme.</p> + <p>The standard system widgets and overall look have been redesigned and incorporate a new +"holographic" user interface theme. The system applies the new theme +using the standard <a href="{@docRoot}guide/topics/ui/themes.html">style and theme</a> system.</p> + +<p>Any application that targets the Android 3.0 platform—by setting either the <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a> +or <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code +android:targetSdkVersion}</a> value to {@code "11"}—inherits the holographic theme by default. +However, if your application also applies its own theme, then your theme will override the +holographic theme, unless you update your styles to inherit the holographic theme.</p> <p>To apply the holographic theme to individual activities or to inherit them in your own theme definitions, use one of several new {@link android.R.style#Theme_Holo Theme.Holo} -themes.</p> +themes. If your application is compatible with version of Android lower than 3.0 and applies +custom themes, then you should <a +href="{@docRoot}guide/topics/ui/themes.html#SelectATheme">select a theme based on platform +version</a>.</p> + </li> @@ -430,38 +529,36 @@ themes.</p> each child at a regular interval.</p></li> <li>{@link android.widget.CalendarView} - <p>Allows users to select dates from a calendar and you can configure the range of dates - available. A user can select a date by tapping on it and can scroll and fling - the calendar to a desired date.</p></li> + <p>Allows users to select dates from a calendar by touching the date and can scroll or fling the +calendar to a desired date. You can configure the range of dates available in the widget.</p></li> <li>{@link android.widget.ListPopupWindow} <p>Anchors itself to a host view and displays a list of choices, such as for a list of suggestions when typing into an {@link android.widget.EditText} view.</p></li> <li>{@link android.widget.NumberPicker} - <p>Enables the user to select a number from a predefined range. The widget presents an - input field and up and down buttons for selecting a number. Touching the input field shows a - scroll wheel that allows the user to scroll through values or touch again to directly edit the - current value. It also allows you to map from positions to strings, so that - the corresponding string is displayed instead of the position index.</p></li> + <p>Enables the user to select a number from a predefined range. The widget presents an input +field and up and down buttons for selecting a number. Touching the input field allows the user to +scroll through values or touch again to directly edit the current value. It also allows you to map +positions to strings, so that the corresponding string is displayed instead of the index +position.</p></li> <li>{@link android.widget.PopupMenu} <p>Displays a {@link android.view.Menu} in a modal popup window that's anchored to a view. The - popup - appears below the anchor view if there is room, or above it if there is not. If the IME (soft - keyboard) is visible, the popup does not overlap it until it is touched.</p></li> +popup appears below the anchor view if there is room, or above it if there is not. If the IME (soft +keyboard) is visible, the popup does not overlap the IME it until the user touches the +menu.</p></li> <li>{@link android.widget.SearchView} - <p>Provides a search box that works in conjunction with a search provider (in the same manner as - the traditional <a href="{@docRoot}guide/topics/search/search-dialog.html">search dialog</a>). -It - also displays recent query suggestions or custom suggestions as configured by the search - provider. This widget is particularly useful for offering search in the Action Bar.</p></li> + <p>Provides a search box that works in conjunction with the Search Manager (in the same manner +as the traditional <a href="{@docRoot}guide/topics/search/search-dialog.html">search dialog</a>). It +can also display recent query suggestions or custom suggestions as configured by the search +provider. This widget is particularly useful for offering search in the <a +href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>.</p></li> <li>{@link android.widget.StackView} - <p>A view that displays its children in a 3D stack and allows users to discretely swipe through - the - children.</p></li> + <p>A view that displays its children in a 3D stack and allows users to swipe through + views like a rolodex.</p></li> </ul> </li> @@ -470,13 +567,6 @@ It - -<!-- -<h3>WebKit</h3> -<h3>JSON (utilities)</h3> - --> - - <h3>Graphics</h3> <ul> @@ -519,7 +609,10 @@ android.view.View#LAYER_TYPE_SOFTWARE} documentation.</p> <p>Renderscript is a runtime 3D framework that provides both an API for building 3D scenes as well as a special, platform-independent shader language for maximum performance. Using Renderscript, you can accelerate graphics operations and data processing. Renderscript is an ideal way to create -high-performance 3D effects for applications, wallpapers, carousels, and more.</p></li> +high-performance 3D effects for applications, wallpapers, carousels, and more.</p> +<p>For more information, see the <a +href="{@docRoot}guide/topics/graphics/renderscript.html">3D Rendering and Computation with +Renderscript</a> documentation.</p></li> </ul> @@ -548,7 +641,9 @@ camera.</p></li> <p>Applications can now pass an M3U playlist URL to the media framework to begin an HTTP Live streaming session. The media framework supports most of the HTTP Live streaming specification, -including adaptive bit rate.</p></li> +including adaptive bit rate. See the <a +href="{@docRoot}guide/appendix/media-formats.html">Supported Media Formats</a> document for +more information.</p></li> <li><b>EXIF data</b> @@ -599,28 +694,327 @@ rights. However, device manufacturers may ship DRM plug-ins with their devices.< +<h3>Keyboard support</h3> +<ul> +<li>Support for Control, Meta, Caps Lock, Num Lock and Scroll Lock modifiers. For more information, +see {@link android.view.KeyEvent#META_CTRL_ON} and related fields.</li> + +<li>Support for full desktop-style keyboards, including support for keys such as Escape, Home, End, +Delete and others. You can determine whether key events are coming from a full keyboard by +querying {@link android.view.KeyCharacterMap#getKeyboardType()} and checking for {@link +android.view.KeyCharacterMap#FULL KeyCharacterMap.FULL}</li> + +<li>{@link android.widget.TextView} now supports keyboard-based cut, copy, paste, and select-all, +using the key combinations Ctrl+X, Ctrl+C, Ctrl+V, and Ctrl+A. It also supports PageUp/PageDown, +Home/End, and keyboard-based text selection.</li> + +<li>{@link android.view.KeyEvent} adds several new methods to make it easier to check the key +modifier state correctly and consistently. See {@link android.view.KeyEvent#hasModifiers(int)}, +{@link android.view.KeyEvent#hasNoModifiers()}, +{@link android.view.KeyEvent#metaStateHasModifiers(int,int) metaStateHasModifiers()}, +{@link android.view.KeyEvent#metaStateHasNoModifiers(int) metaStateHasNoModifiers()}.</li> + +<li>Applications can implement custom keyboard shortcuts by subclassing {@link +android.app.Activity}, {@link android.app.Dialog}, or {@link android.view.View} and implementing +{@link android.app.Activity#onKeyShortcut onKeyShortcut()}. The framework calls this method +whenever a key is combined with Ctrl key. When creating an <a +href="{@docRoot}guide/topics/ui/menus.html#options-menu">Options Menu</a>, you can register keyboard +shortcuts by setting either the {@code android:alphabeticShortcut} or {@code +android:numericShortcut} attribute for each <a +href="{@docRoot}guide/topics/resources/menu-resource.html#item-element">{@code <item>}</a> +element (or with {@link android.view.MenuItem#setShortcut setShortcut()}).</li> + +<li>Android 3.0 includes a new "virtual keyboard" device with the id {@link +android.view.KeyCharacterMap#VIRTUAL_KEYBOARD KeyCharacterMap.VIRTUAL_KEYBOARD}. The virtual +keyboard has a desktop-style US key map which is useful for synthesizing key events for testing +input.</li> +</ul> -<h2 id="api-level">API Level</h2> -<p>The Android 3.0 platform delivers an updated version of -the framework API. Because this is a preview of the Android 3.0 API, it uses a provisional API -level of "Honeycomb", instead of an integer identifier, which will be provided when the final SDK -is made available and all APIs are final.</p> +<h3>Split touch events</h3> + +<p>Previously, only a single view could accept touch events at one time. Android 3.0 +adds support for splitting touch events across views and even windows, so different views can accept +simultaneous touch events.</p> + +<p>Split touch events is enabled by default when an application targets +Android 3.0. That is, when the application has set either the <a +href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a> +or <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code +android:targetSdkVersion}</a> attribute's value to {@code "11"}.</p> + +<p>However, the following properties allow you to disable split touch events across views inside +specific view groups and across windows.</p> + +<ul> +<li>The {@link android.R.attr#splitMotionEvents android:splitMotionEvents} attribute for view groups +allows you to disable split touch events that occur between child views in a layout. For example: +<pre> +<LinearLayout android:splitMotionEvents="false" ... > + ... +</LinearLayout> +</pre> +<p>This way, child views in the linear layout cannot split touch events—only one view can +receive touch events at a time.</p> +</li> + +<li>The {@link android.R.attr#windowEnableSplitTouch android:windowEnableSplitTouch} style property +allows you to disable split touch events across windows, by applying it to a theme for the activity +or entire application. For example: +<pre> +<style name="NoSplitMotionEvents" parent="android:Theme.Holo"> + <item name="android:windowEnableSplitTouch">false</item> + ... +</style> +</pre> +<p>When this theme is applied to an <a +href="{@docRoot}guide/topics/manifest/activity-element.html">{@code <activity>}</a> or <a +href="{@docRoot}guide/topics/manifest/application-element.html">{@code <application>}</a>, +only touch events within the current activity window are accepted. For example, by disabling split +touch events across windows, the system bar cannot receive touch events at the same time as the +activity. This does <em>not</em> affect whether views inside the activity can split touch +events—by default, the activity can still split touch events across views.</p> + +<p>For more information about creating a theme, read <a +href="{@docRoot}guide/topics/ui/themes.html">Applying Styles and Themes</a>.</p> +</li> +</ul> + + + +<h3>WebKit</h3> + +<ul> + <li>New {@link android.webkit.WebViewFragment} class to create a fragment composed of a +{@link android.webkit.WebView}.</li> + <li>New {@link android.webkit.WebSettings} methods: + <ul> + <li>{@link +android.webkit.WebSettings#setDisplayZoomControls setDisplayZoomControls()} allows you to hide +the on-screen zoom controls while still allowing the user to zoom with finger gestures ({@link +android.webkit.WebSettings#setBuiltInZoomControls setBuiltInZoomControls()} must be set +{@code true}).</li> + <li>New {@link android.webkit.WebSettings} method, {@link +android.webkit.WebSettings#setEnableSmoothTransition setEnableSmoothTransition()}, allows you +to enable smooth transitions when panning and zooming. When enabled, WebView will choose a solution +to maximize the performance (for example, the WebView's content may not update during the +transition).</li> + </ul> + <li>New {@link android.webkit.WebView} methods: + <ul> + <li>{@link android.webkit.WebView#onPause onPause()} callback, to pause any processing +associated with the WebView when it becomes hidden. This is useful to reduce unnecessary CPU or +network traffic when the WebView is not in the foreground.</li> + <li>{@link android.webkit.WebView#onResume onResume()} callback, to resume processing +associated with the WebView, which was paused during {@link android.webkit.WebView#onPause +onPause()}.</li> + <li>{@link android.webkit.WebView#saveWebArchive saveWebArchive()} allows you to save the +current view as a web archive on the device.</li> + <li>{@link android.webkit.WebView#showFindDialog showFindDialog()} initiates a text search in +the current view.</li> + </ul> + </li> +</ul> + -<p>To use APIs introduced in Android 3.0 in your application, you need compile the application -against the Android library that is provided in the Android 3.0 preview SDK platform and you must -declare this API Level in your manifest as <code>android:minSdkVersion="Honeycomb"</code>, in the -<code><uses-sdk></code> element in the application's manifest.</p> -<p>For more information about using this provisional API Level and setting up your environment -to use the preview SDK, please see the <a href="{@docRoot}sdk/preview/start.html">Getting -Started</a> document.</p> +<h3>Browser</h3> + +<p>The Browser application adds the following features to support web applications:</p> + +<ul> + <li><b>Media capture</b> + <p>As defined by the <a href="http://dev.w3.org/2009/dap/camera/">HTML Media Capture</a> +specification, the Browser allows web applications to access audio, image and video capture +capabilities of the device. For example, the following HTML provides an input for the user to +capture a photo to upload:</p> +<pre> +<input type="file" accept="image/*;capture=camera" /> +</pre> +<p>Or by excluding the {@code capture=camera} parameter, the user can choose to either capture a +new image with the camera or select one from the device (such as from the Gallery application).</p> + </li> + + <li><b>Device Orientation</b> + <p>As defined by the <a +href="http://dev.w3.org/geo/api/spec-source-orientation.html">Device Orientation Event</a> +specification, the Browser allows web applications to listen to DOM events that provide information +about the physical orientation and motion of the device.</p> + <p>The device orientation is expressed with the x, y, and z axes, in degrees and motion is +expressed with acceleration and rotation rate data. A web page can register for orientation +events by calling {@code window.addEventListener} with event type {@code "deviceorientation"} +and register for motion events by registering the {@code "devicemotion"} event type.</p> + </li> + + <li><b>CSS 3D Transforms</b> + <p>As defined by the <a href="http://www.w3.org/TR/css3-3d-transforms/">CSS 3D Transform +Module</a> specification, the Browser allows elements rendered by CSS to be transformed in three +dimensions.</p> + </li> +</ul> + + + +<h3>JSON utilities</h3> + +<p>New classes, {@link android.util.JsonReader} and {@link android.util.JsonWriter}, help you +read and write JSON streams. The new APIs compliment the {@link org.json} classes which manipulate a +document in memory.</p> + +<p>You can create an instance of {@link android.util.JsonReader} by calling +its constructor method and passing the {@link java.io.InputStreamReader} that feeds the JSON string. +Then begin reading an object by calling {@link android.util.JsonReader#beginObject()}, read a +key name with {@link android.util.JsonReader#nextName()}, read the value using methods +respective to the type, such as {@link android.util.JsonReader#nextString()} and {@link +android.util.JsonReader#nextInt()}, and continue doing so while {@link +android.util.JsonReader#hasNext()} is true.</p> + +<p>You can create an instance of {@link android.util.JsonWriter} by calling its constructor and +passing the appropriate {@link java.io.OutputStreamWriter}. Then write the JSON data in a manner +similar to the reader, using {@link android.util.JsonWriter#name name()} to add a property name +and an appropriate {@link android.util.JsonWriter#value value()} method to add the respective +value.</p> + +<p>These classes are strict by default. The {@link android.util.JsonReader#setLenient setLenient()} +method in each class configures them to be more liberal in what they accept. This lenient +parse mode is also compatible with the {@link org.json}'s default parser.</p> + + + + +<h3>New feature constants</h3> + +<p>The <a +href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a> +manfest element should be used to inform external entities (such as Android Market) of the set of +hardware and software features on which your application depends. In this release, Android adds the +following new constants that applications can declare with this element:</p> + +<ul> + <li>{@link android.content.pm.PackageManager#FEATURE_FAKETOUCH "android.hardware.faketouch"} + <p>When declared, this indicates that the application is compatible with a device that offers an +emulated touchscreen (or better). A device that offers an emulated touchscreen provides a user input +system that can emulate a subset of touchscreen +capabilities. An example of such an input system is a mouse or remote control that drives an +on-screen cursor. Such input systems support basic touch events like click down, click up, and drag. +However, more complicated input types (such as gestures, flings, etc.) may be more difficult or +impossible on faketouch devices (and multitouch gestures are definitely not possible).</p> + <p>If your application does <em>not</em> require complicated gestures and you do +<em>not</em> want your application filtered from devices with an emulated touchscreen, you +should declare {@link +android.content.pm.PackageManager#FEATURE_FAKETOUCH "android.hardware.faketouch"} with a <a +href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a> +element. This way, your application will be available to the greatest number of device types, +including those that provide only an emulated touchscreen input.</p> + <p>All devices that include a touchscreen also support {@link +android.content.pm.PackageManager#FEATURE_FAKETOUCH "android.hardware.faketouch"}, because +touchscreen capabilities are a superset of faketouch capabilities. Thus, unless you actually require +a touchscreen, you should add a <a +href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a> +element for faketouch.</p> + </li> +</ul> + + + + +<h3>New permissions</h3> + +<ul> + <li>{@link android.Manifest.permission#BIND_REMOTEVIEWS +"android.permission.BIND_REMOTEVIEWS"} + <p>This must be declared as a required permission in the <a +href="{@docRoot}guide/topics/manifest/service-element.html">{@code <service>}</a> manifest +element for an implementation of {@link android.widget.RemoteViewsService}. For example, when +creating an App Widget that uses {@link android.widget.RemoteViewsService} to populate a +collection view, the manifest entry may look like this:</p> +<pre> +<service android:name=".widget.WidgetService" + android:exported="false" + android:permission="android.permission.BIND_REMOTEVIEWS" /> +</pre> +</ul> + + + +<h3>New platform technologies</h3> + +<ul> +<li><strong>Storage</strong> + <ul> + <li>ext4 file system support to enable onboard eMMC storage.</li> + <li>FUSE file system to support MTP devices.</li> + <li>USB host mode support to support keyboards and USB hubs.</li> + <li>Support for MTP/PTP </li> + </ul> +</li> + +<li><strong>Linux Kernel</strong> + <ul> + <li>Upgraded to 2.6.36</li> + </ul> +</li> + +<li><strong>Dalvik VM</strong> + <ul> + <li>New code to support and optimize for SMP</li> + <li>Various improvements to the JIT infrastructure</li> + <li>Garbage collector improvements: + <ul> + <li>Tuned for SMP</li> + <li>Support for larger heap sizes</li> + <li>Unified handling for bitmaps and byte buffers</li> + </ul> + </li> + </ul> +</li> + +<li><strong>Dalvik Core Libraries</strong> + <ul> + <li>New, much faster implementation of NIO (modern I/O library)</li> + <li>Improved exception messages</li> + <li>Correctness and performance fixes throughout</li> + </ul> +</li> +</ul> + + + +<h3 id="api-diff">API differences report</h3> + +<p>For a detailed view of all API changes in Android {@sdkPlatformVersion} (API Level +{@sdkPlatformApiLevel}), see the <a +href="{@docRoot}sdk/api_diff/{@sdkPlatformApiLevel}/changes.html">API Differences Report</a>.</p> + + + + + +<h2 id="api-level">API Level</h2> + +<p>The Android {@sdkPlatformVersion} platform delivers an updated version of +the framework API. The Android {@sdkPlatformVersion} API +is assigned an integer identifier — +<strong>{@sdkPlatformApiLevel}</strong> — that is +stored in the system itself. This identifier, called the "API Level", allows the +system to correctly determine whether an application is compatible with +the system, prior to installing the application. </p> +<p>To use APIs introduced in Android {@sdkPlatformVersion} in your application, +you need compile the application against the Android library that is provided in +the Android {@sdkPlatformVersion} SDK platform. Depending on your needs, you might +also need to add an <code>android:minSdkVersion="{@sdkPlatformApiLevel}"</code> +attribute to the <code><uses-sdk></code> element in the application's +manifest. If your application is designed to run only on Android 2.3 and higher, +declaring the attribute prevents the application from being installed on earlier +versions of the platform.</p> +<p>For more information about how to use API Level, see the <a +href="{@docRoot}guide/appendix/api-levels.html">API Levels</a> document. </p> <h2 id="apps">Built-in Applications</h2> @@ -632,6 +1026,7 @@ built-in applications:</p> <tr> <td style="border:0;padding-bottom:0;margin-bottom:0;"> <ul> +<li>API Demos</li> <li>Browser</li> <li>Calculator</li> <li>Camera</li> @@ -646,11 +1041,14 @@ built-in applications:</p> <td style="border:0;padding-bottom:0;margin-bottom:0;padding-left:5em;"> <ul> <li>Gallery</li> +<li>Gestures Builder</li> +<li>Messaging</li> <li>Music</li> <li>Search</li> <li>Settings</li> -<li>Spare Parts (developer app)</li> +<li>Spare Parts</li> <li>Speech Recorder</li> +<li>Widget Preview</li> </ul> </td> </tr> diff --git a/docs/html/sdk/sdk_toc.cs b/docs/html/sdk/sdk_toc.cs index 2ba8076..1b94b2c 100644 --- a/docs/html/sdk/sdk_toc.cs +++ b/docs/html/sdk/sdk_toc.cs @@ -40,25 +40,15 @@ if:sdk.preview ?> <li><h2>Android 3.0 Preview SDK</h2> <ul> - <li><a href="<?cs var:toroot ?>sdk/preview/start.html">Getting Started</a> <span class="new">new!</span></li> - <li class="toggle-list"> - <div><a href="<?cs var:toroot ?>sdk/android-3.0.html"> - <span class="en">Android 3.0 Platform</span></a> <span class="new">new!</span></div> - <ul> - <li><a href="<?cs var:toroot ?>sdk/api_diff/honeycomb/changes.html">API Differences Report -»</a></li> - </ul> - </li> + <li><a href="<?cs var:toroot ?>sdk/preview/start.html">Getting Started</a> <span +class="new">new!</span></li> </ul> </li><?cs /if ?> <?cs if:sdk.preview ?> - <li><h2>Android 3.0 Preview</h2> + <li><h2>Android x.x Preview</h2> <ul> - <li><a href="<?cs var:toroot ?>sdk/android-3.0-highlights.html">Platform Highlights</a> <span -class="new">new!</span></li> - <li><a href="<?cs var:toroot ?>sdk/preview/index.html">SDK</a> <span class="new">new!</span></li> </ul> </li><?cs /if ?> @@ -87,18 +77,19 @@ class="new">new!</span></li> </ul> <ul> <li class="toggle-list"> - <div><a href="<?cs var:toroot ?>sdk/android-2.3.3.html"> - <span class="en">Android 2.3.3 Platform</span></a> <span class="new">new!</span></div> + <div><a href="<?cs var:toroot ?>sdk/android-3.0.html"> + <span class="en">Android 3.0 Platform</span></a> <span class="new">new!</span></div> <ul> - <li><a href="<?cs var:toroot ?>sdk/api_diff/10/changes.html">API Differences Report »</a></li> + <li><a href="<?cs var:toroot ?>sdk/android-3.0-highlights.html">Platform Highlights</a></li> + <li><a href="<?cs var:toroot ?>sdk/api_diff/11/changes.html">API Differences Report »</a></li> </ul> </li> <li class="toggle-list"> - <div><a href="<?cs var:toroot ?>sdk/android-2.3.html"> - <span class="en">Android 2.3 Platform</span></a></div> + <div><a href="<?cs var:toroot ?>sdk/android-2.3.3.html"> + <span class="en">Android 2.3.3 Platform</span></a> <span class="new">new!</span></div> <ul> <li><a href="<?cs var:toroot ?>sdk/android-2.3-highlights.html">Platform Highlights</a></li> - <li><a href="<?cs var:toroot ?>sdk/api_diff/9/changes.html">API Differences Report »</a></li> + <li><a href="<?cs var:toroot ?>sdk/api_diff/10/changes.html">API Differences Report »</a></li> </ul> </li> <li><a href="<?cs var:toroot ?>sdk/android-2.2.html">Android 2.2 Platform</a></li> @@ -108,6 +99,13 @@ class="new">new!</span></li> <li class="toggle-list"> <div><a href="#" onclick="toggle(this.parentNode.parentNode,true); return false;">Older Platforms</a></div> <ul> + <li class="toggle-list"> + <div><a href="<?cs var:toroot ?>sdk/android-2.3.html"> + <span class="en">Android 2.3 Platform</span></a></div> + <ul> + <li><a href="<?cs var:toroot ?>sdk/api_diff/9/changes.html">API Differences Report »</a></li> + </ul> + </li> <li><a href="<?cs var:toroot ?>sdk/android-2.0.1.html">Android 2.0.1 Platform</a></li> <li><a href="<?cs var:toroot ?>sdk/android-2.0.html">Android 2.0 Platform</a></li> <li><a href="<?cs var:toroot ?>sdk/android-1.1.html">Android 1.1 Platform</a></li> @@ -115,7 +113,7 @@ class="new">new!</span></li> </li> </ul> <ul> - <li><a href="<?cs var:toroot ?>sdk/tools-notes.html">SDK Tools, r9</a> <span class="new">new!</span></li> + <li><a href="<?cs var:toroot ?>sdk/tools-notes.html">SDK Tools, r10</a> <span class="new">new!</span></li> <li><a href="<?cs var:toroot ?>sdk/win-usb.html">Google USB Driver, r4</a></li> </ul> </li> @@ -131,7 +129,7 @@ class="new">new!</span></li> <span style="display:none" class="zh-TW"></span> </h2> <ul> - <li><a href="<?cs var:toroot ?>sdk/eclipse-adt.html">ADT 9.0.0 + <li><a href="<?cs var:toroot ?>sdk/eclipse-adt.html">ADT 10.0.0 <span style="display:none" class="de"></span> <span style="display:none" class="es"></span> <span style="display:none" class="fr"></span> @@ -153,7 +151,7 @@ class="new">new!</span></li> <span style="display:none" class="zh-TW"></span> </h2> <ul> - <li><a href="<?cs var:toroot ?>sdk/ndk/index.html">Android NDK, r5b</a> + <li><a href="<?cs var:toroot ?>sdk/ndk/index.html">Android NDK, r6</a> <span class="new">new!</span></li> <li><a href="<?cs var:toroot ?>sdk/ndk/overview.html">What is the NDK?</a></li> </ul> diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index e368848..cb08023 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -399,6 +399,9 @@ void AwesomePlayer::reset_l() { if (mConnectingDataSource != NULL) { LOGI("interrupting the connection process"); mConnectingDataSource->disconnect(); + } else if (mConnectingRTSPController != NULL) { + LOGI("interrupting the connection process"); + mConnectingRTSPController->disconnect(); } if (mFlags & PREPARING_CONNECTED) { @@ -409,7 +412,7 @@ void AwesomePlayer::reset_l() { } if (mFlags & PREPARING) { - LOGI("waiting until preparation is completes."); + LOGI("waiting until preparation is completed."); } while (mFlags & PREPARING) { @@ -1633,7 +1636,13 @@ status_t AwesomePlayer::finishSetDataSource_l() { mLooper->start(); } mRTSPController = new ARTSPController(mLooper); + mConnectingRTSPController = mRTSPController; + + mLock.unlock(); status_t err = mRTSPController->connect(mUri.string()); + mLock.lock(); + + mConnectingRTSPController.clear(); LOGI("ARTSPController::connect returned %d", err); diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h index 797e5ca..98b8c05 100644 --- a/media/libstagefright/include/AwesomePlayer.h +++ b/media/libstagefright/include/AwesomePlayer.h @@ -205,6 +205,7 @@ private: sp<ALooper> mLooper; sp<ARTSPController> mRTSPController; + sp<ARTSPController> mConnectingRTSPController; sp<LiveSession> mLiveSession; diff --git a/media/libstagefright/rtsp/ARTSPController.cpp b/media/libstagefright/rtsp/ARTSPController.cpp index a7563ff..1328d2e 100644 --- a/media/libstagefright/rtsp/ARTSPController.cpp +++ b/media/libstagefright/rtsp/ARTSPController.cpp @@ -69,7 +69,14 @@ status_t ARTSPController::connect(const char *url) { void ARTSPController::disconnect() { Mutex::Autolock autoLock(mLock); - if (mState != CONNECTED) { + if (mState == CONNECTING) { + mState = DISCONNECTED; + mConnectionResult = ERROR_IO; + mCondition.broadcast(); + + mHandler.clear(); + return; + } else if (mState != CONNECTED) { return; } diff --git a/media/tests/contents/media_api/videoeditor/H264_BP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4 b/media/tests/contents/media_api/videoeditor/H264_BP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4 Binary files differnew file mode 100755 index 0000000..be050dc --- /dev/null +++ b/media/tests/contents/media_api/videoeditor/H264_BP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4 diff --git a/media/tests/contents/media_api/videoeditor/IMG_640x480_Overlay2.png b/media/tests/contents/media_api/videoeditor/IMG_640x480_Overlay2.png Binary files differindex 6611986..0f32131a 100644..100755 --- a/media/tests/contents/media_api/videoeditor/IMG_640x480_Overlay2.png +++ b/media/tests/contents/media_api/videoeditor/IMG_640x480_Overlay2.png diff --git a/media/tests/contents/media_api/videoeditor/MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp b/media/tests/contents/media_api/videoeditor/MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp Binary files differdeleted file mode 100644 index bd8b079..0000000 --- a/media/tests/contents/media_api/videoeditor/MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp +++ /dev/null diff --git a/media/tests/contents/media_api/videoeditor/Text_FileRenamedTo3gp.3gp b/media/tests/contents/media_api/videoeditor/Text_FileRenamedTo3gp.3gp new file mode 100644 index 0000000..02103c6 --- /dev/null +++ b/media/tests/contents/media_api/videoeditor/Text_FileRenamedTo3gp.3gp @@ -0,0 +1 @@ +This is a text file
\ No newline at end of file diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_recent_item.xml b/packages/SystemUI/res/layout-xlarge/status_bar_recent_item.xml index 3fdfdbb..c358e13 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar_recent_item.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar_recent_item.xml @@ -40,6 +40,9 @@ android:layout_alignParentTop="true" android:layout_marginLeft="123dip" android:layout_marginTop="16dip" + android:maxWidth="64dip" + android:maxHeight="64dip" + android:adjustViewBounds="true" /> <View android:id="@+id/recents_callout_line" diff --git a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java index 6c6c2cc..018fe0c 100644 --- a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java +++ b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java @@ -361,10 +361,12 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient /** {@inheritDoc} */ public void cleanUp() { + if (DEBUG) Log.v(TAG, "Cleanup() called on " + this); mUpdateMonitor.removeCallback(this); mLockPatternUtils = null; mUpdateMonitor = null; mCallback = null; + mLockPatternView.setOnPatternListener(null); } @Override @@ -406,6 +408,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient mCallback.keyguardDone(true); mCallback.reportSuccessfulUnlockAttempt(); } else { + boolean reportFailedAttempt = false; if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) { mCallback.pokeWakelock(UNLOCK_PATTERN_WAKE_INTERVAL_MS); } @@ -413,9 +416,10 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) { mTotalFailedPatternAttempts++; mFailedPatternAttemptsSinceLastTimeout++; - mCallback.reportFailedUnlockAttempt(); + reportFailedAttempt = true; } - if (mFailedPatternAttemptsSinceLastTimeout >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) { + if (mFailedPatternAttemptsSinceLastTimeout + >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) { long deadline = mLockPatternUtils.setLockoutAttemptDeadline(); handleAttemptLockout(deadline); } else { @@ -427,6 +431,12 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient mCancelPatternRunnable, PATTERN_CLEAR_TIMEOUT_MS); } + + // Because the following can result in cleanUp() being called on this screen, + // member variables reset in cleanUp() shouldn't be accessed after this call. + if (reportFailedAttempt) { + mCallback.reportFailedUnlockAttempt(); + } } } } diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java index ff5f989..f24f96c 100644 --- a/services/java/com/android/server/connectivity/Tethering.java +++ b/services/java/com/android/server/connectivity/Tethering.java @@ -90,7 +90,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { private BroadcastReceiver mStateReceiver; private static final String USB_NEAR_IFACE_ADDR = "192.168.42.129"; - private static final String USB_NETMASK = "255.255.255.0"; + private static final int USB_PREFIX_LENGTH = 24; // USB is 192.168.42.1 and 255.255.255.0 // Wifi is 192.168.43.1 and 255.255.255.0 @@ -568,8 +568,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { ifcg = service.getInterfaceConfig(iface); if (ifcg != null) { InetAddress addr = InetAddress.getByName(USB_NEAR_IFACE_ADDR); - InetAddress mask = InetAddress.getByName(USB_NETMASK); - ifcg.addr = new LinkAddress(addr, mask); + ifcg.addr = new LinkAddress(addr, USB_PREFIX_LENGTH); if (enabled) { ifcg.interfaceFlags = ifcg.interfaceFlags.replace("down", "up"); } else { |