summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/ActivityThread.java7
-rw-r--r--core/java/android/app/Application.java11
-rw-r--r--core/java/android/app/ApplicationThreadNative.java1
-rw-r--r--core/java/android/app/DownloadManager.java7
-rw-r--r--core/java/android/app/SharedPreferencesImpl.java67
-rwxr-xr-x[-rw-r--r--]core/java/android/app/admin/DevicePolicyManager.java6
-rw-r--r--core/java/android/bluetooth/BluetoothDeviceProfileState.java48
-rw-r--r--core/java/android/content/SyncStorageEngine.java7
-rw-r--r--core/java/android/database/AbstractCursor.java3
-rw-r--r--core/java/android/hardware/Camera.java51
-rw-r--r--core/java/android/net/DhcpStateMachine.java17
-rw-r--r--core/java/android/net/EthernetDataTracker.java2
-rw-r--r--core/java/android/net/MobileDataStateTracker.java113
-rw-r--r--core/java/android/net/NetworkStateTracker.java6
-rw-r--r--core/java/android/net/VpnService.java2
-rw-r--r--core/java/android/net/arp/ArpPeer.java8
-rw-r--r--core/java/android/os/FileUtils.java51
-rw-r--r--core/java/android/os/Process.java10
-rw-r--r--core/java/android/os/SELinux.java176
-rw-r--r--core/java/android/os/StatFs.java86
-rw-r--r--core/java/android/os/StrictMode.java6
-rw-r--r--core/java/android/os/storage/StorageManager.java23
-rw-r--r--core/java/android/provider/CallLog.java8
-rwxr-xr-x[-rw-r--r--]core/java/android/provider/ContactsContract.java2
-rwxr-xr-xcore/java/android/provider/Telephony.java2037
-rwxr-xr-xcore/java/android/server/BluetoothService.java2
-rw-r--r--core/java/android/text/format/DateUtils.java33
-rw-r--r--core/java/android/view/FocusFinder.java4
-rw-r--r--core/java/android/view/SurfaceView.java2
-rw-r--r--core/java/android/view/View.java12
-rw-r--r--core/java/android/webkit/WebViewClassic.java14
-rw-r--r--core/java/android/widget/Gallery.java8
-rw-r--r--core/java/android/widget/GridView.java7
-rw-r--r--core/java/android/widget/HorizontalScrollView.java13
-rw-r--r--core/java/android/widget/MediaController.java3
-rw-r--r--core/java/android/widget/ScrollView.java14
-rw-r--r--core/java/android/widget/SearchView.java7
-rw-r--r--core/java/android/widget/SimpleExpandableListAdapter.java52
-rw-r--r--core/java/android/widget/Switch.java2
-rw-r--r--core/java/android/widget/TabHost.java71
40 files changed, 702 insertions, 2297 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 7242029..b7e0683 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -4728,13 +4728,14 @@ public final class ActivityThread {
Process.setArgV0("<pre-initialized>");
Looper.prepareMainLooper();
- if (sMainThreadHandler == null) {
- sMainThreadHandler = new Handler();
- }
ActivityThread thread = new ActivityThread();
thread.attach(false);
+ if (sMainThreadHandler == null) {
+ sMainThreadHandler = thread.getHandler();
+ }
+
AsyncTask.init();
if (false) {
diff --git a/core/java/android/app/Application.java b/core/java/android/app/Application.java
index dd9ea26..3a67cec 100644
--- a/core/java/android/app/Application.java
+++ b/core/java/android/app/Application.java
@@ -64,11 +64,12 @@ public class Application extends ContextWrapper implements ComponentCallbacks2 {
}
/**
- * Called when the application is starting, before any other application
- * objects have been created. Implementations should be as quick as
- * possible (for example using lazy initialization of state) since the time
- * spent in this function directly impacts the performance of starting the
- * first activity, service, or receiver in a process.
+ * Called when the application is starting, before any activity, service,
+ * or receiver objects (excluding content providers) have been created.
+ * Implementations should be as quick as possible (for example using
+ * lazy initialization of state) since the time spent in this function
+ * directly impacts the performance of starting the first activity,
+ * service, or receiver in a process.
* If you override this method, be sure to call super.onCreate().
*/
public void onCreate() {
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index 3e726e0..8e6278d 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -385,6 +385,7 @@ public abstract class ApplicationThreadNative extends Binder
case SCHEDULE_LOW_MEMORY_TRANSACTION:
{
+ data.enforceInterface(IApplicationThread.descriptor);
scheduleLowMemory();
return true;
}
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index 17700f9..0b1c524 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -344,6 +344,13 @@ public class DownloadManager {
*/
public static final int NETWORK_WIFI = 1 << 1;
+ /**
+ * Bit flag for {@link #setAllowedNetworkTypes} corresponding to
+ * {@link ConnectivityManager#TYPE_BLUETOOTH}.
+ * @hide
+ */
+ public static final int NETWORK_BLUETOOTH = 1 << 2;
+
private Uri mUri;
private Uri mDestinationUri;
private List<Pair<String, String>> mRequestHeaders = new ArrayList<Pair<String, String>>();
diff --git a/core/java/android/app/SharedPreferencesImpl.java b/core/java/android/app/SharedPreferencesImpl.java
index 615e8ce..201d7b2 100644
--- a/core/java/android/app/SharedPreferencesImpl.java
+++ b/core/java/android/app/SharedPreferencesImpl.java
@@ -17,7 +17,6 @@
package android.app;
import android.content.SharedPreferences;
-import android.os.FileUtils.FileStatus;
import android.os.FileUtils;
import android.os.Looper;
import android.util.Log;
@@ -45,6 +44,11 @@ import java.util.WeakHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
+import libcore.io.ErrnoException;
+import libcore.io.IoUtils;
+import libcore.io.Libcore;
+import libcore.io.StructStat;
+
final class SharedPreferencesImpl implements SharedPreferences {
private static final String TAG = "SharedPreferencesImpl";
private static final boolean DEBUG = false;
@@ -105,26 +109,32 @@ final class SharedPreferencesImpl implements SharedPreferences {
}
Map map = null;
- FileStatus stat = new FileStatus();
- if (FileUtils.getFileStatus(mFile.getPath(), stat) && mFile.canRead()) {
- try {
- BufferedInputStream str = new BufferedInputStream(
- new FileInputStream(mFile), 16*1024);
- map = XmlUtils.readMapXml(str);
- str.close();
- } catch (XmlPullParserException e) {
- Log.w(TAG, "getSharedPreferences", e);
- } catch (FileNotFoundException e) {
- Log.w(TAG, "getSharedPreferences", e);
- } catch (IOException e) {
- Log.w(TAG, "getSharedPreferences", e);
+ StructStat stat = null;
+ try {
+ stat = Libcore.os.stat(mFile.getPath());
+ if (mFile.canRead()) {
+ BufferedInputStream str = null;
+ try {
+ str = new BufferedInputStream(
+ new FileInputStream(mFile), 16*1024);
+ map = XmlUtils.readMapXml(str);
+ } catch (XmlPullParserException e) {
+ Log.w(TAG, "getSharedPreferences", e);
+ } catch (FileNotFoundException e) {
+ Log.w(TAG, "getSharedPreferences", e);
+ } catch (IOException e) {
+ Log.w(TAG, "getSharedPreferences", e);
+ } finally {
+ IoUtils.closeQuietly(str);
+ }
}
+ } catch (ErrnoException e) {
}
mLoaded = true;
if (map != null) {
mMap = map;
- mStatTimestamp = stat.mtime;
- mStatSize = stat.size;
+ mStatTimestamp = stat.st_mtime;
+ mStatSize = stat.st_size;
} else {
mMap = new HashMap<String, Object>();
}
@@ -155,12 +165,21 @@ final class SharedPreferencesImpl implements SharedPreferences {
return false;
}
}
- FileStatus stat = new FileStatus();
- if (!FileUtils.getFileStatus(mFile.getPath(), stat)) {
+
+ final StructStat stat;
+ try {
+ /*
+ * Metadata operations don't usually count as a block guard
+ * violation, but we explicitly want this one.
+ */
+ BlockGuard.getThreadPolicy().onReadFromDisk();
+ stat = Libcore.os.stat(mFile.getPath());
+ } catch (ErrnoException e) {
return true;
}
+
synchronized (this) {
- return mStatTimestamp != stat.mtime || mStatSize != stat.size;
+ return mStatTimestamp != stat.st_mtime || mStatSize != stat.st_size;
}
}
@@ -577,12 +596,14 @@ final class SharedPreferencesImpl implements SharedPreferences {
FileUtils.sync(str);
str.close();
ContextImpl.setFilePermissionsFromMode(mFile.getPath(), mMode, 0);
- FileStatus stat = new FileStatus();
- if (FileUtils.getFileStatus(mFile.getPath(), stat)) {
+ try {
+ final StructStat stat = Libcore.os.stat(mFile.getPath());
synchronized (this) {
- mStatTimestamp = stat.mtime;
- mStatSize = stat.size;
+ mStatTimestamp = stat.st_mtime;
+ mStatSize = stat.st_size;
}
+ } catch (ErrnoException e) {
+ // Do nothing
}
// Writing was successful, delete the backup file if there is one.
mBackupFile.delete();
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 4ed0766..0b58396 100644..100755
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -1008,13 +1008,15 @@ public class DevicePolicyManager {
/**
* Ask the user date be wiped. This will cause the device to reboot,
* erasing all user data while next booting up. External storage such
- * as SD cards will not be erased.
+ * as SD cards will be also erased if the flag {@link #WIPE_EXTERNAL_STORAGE}
+ * is set.
*
* <p>The calling device admin must have requested
* {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to be able to call
* this method; if it has not, a security exception will be thrown.
*
- * @param flags Bit mask of additional options: currently must be 0.
+ * @param flags Bit mask of additional options: currently 0 and
+ * {@link #WIPE_EXTERNAL_STORAGE} are supported.
*/
public void wipeData(int flags) {
if (mService != null) {
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index c9603bf..020f051 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -304,6 +304,25 @@ public final class BluetoothDeviceProfileState extends StateMachine {
}
}
+ @Override
+ protected void onQuitting() {
+ mContext.unregisterReceiver(mBroadcastReceiver);
+ mBroadcastReceiver = null;
+ mAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mHeadsetService);
+ mBluetoothProfileServiceListener = null;
+ mOutgoingHandsfree = null;
+ mPbap = null;
+ mPbapService.close();
+ mPbapService = null;
+ mIncomingHid = null;
+ mOutgoingHid = null;
+ mIncomingHandsfree = null;
+ mOutgoingHandsfree = null;
+ mIncomingA2dp = null;
+ mOutgoingA2dp = null;
+ mBondedDevice = null;
+ }
+
private class BondedDevice extends State {
@Override
public void enter() {
@@ -416,26 +435,6 @@ public final class BluetoothDeviceProfileState extends StateMachine {
case TRANSITION_TO_STABLE:
// ignore.
break;
- case SM_QUIT_CMD:
- mContext.unregisterReceiver(mBroadcastReceiver);
- mBroadcastReceiver = null;
- mAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mHeadsetService);
- mBluetoothProfileServiceListener = null;
- mOutgoingHandsfree = null;
- mPbap = null;
- mPbapService.close();
- mPbapService = null;
- mIncomingHid = null;
- mOutgoingHid = null;
- mIncomingHandsfree = null;
- mOutgoingHandsfree = null;
- mIncomingA2dp = null;
- mOutgoingA2dp = null;
- mBondedDevice = null;
- // There is a problem in the State Machine code
- // where things are not cleaned up properly, when quit message
- // is handled so return NOT_HANDLED as a workaround.
- return NOT_HANDLED;
default:
return NOT_HANDLED;
}
@@ -1341,6 +1340,15 @@ public final class BluetoothDeviceProfileState extends StateMachine {
return mDevice;
}
+ /**
+ * Quit the state machine, only to be called by BluetoothService.
+ *
+ * @hide
+ */
+ public void doQuit() {
+ this.quit();
+ }
+
private void log(String message) {
if (DBG) {
Log.i(TAG, "Device:" + mDevice + " Message:" + message);
diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java
index 226e107..7a9fc65 100644
--- a/core/java/android/content/SyncStorageEngine.java
+++ b/core/java/android/content/SyncStorageEngine.java
@@ -26,6 +26,7 @@ import org.xmlpull.v1.XmlSerializer;
import android.accounts.Account;
import android.accounts.AccountAndUser;
+import android.content.res.Resources;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
@@ -337,6 +338,7 @@ public class SyncStorageEngine extends Handler {
private int mNextHistoryId = 0;
private SparseArray<Boolean> mMasterSyncAutomatically = new SparseArray<Boolean>();
+ private boolean mDefaultMasterSyncAutomatically;
private OnSyncRequestListener mSyncRequestListener;
@@ -346,6 +348,9 @@ public class SyncStorageEngine extends Handler {
mCal = Calendar.getInstance(TimeZone.getTimeZone("GMT+0"));
+ mDefaultMasterSyncAutomatically = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_syncstorageengine_masterSyncAutomatically);
+
File systemDir = new File(dataDir, "system");
File syncDir = new File(systemDir, "sync");
syncDir.mkdirs();
@@ -781,7 +786,7 @@ public class SyncStorageEngine extends Handler {
public boolean getMasterSyncAutomatically(int userId) {
synchronized (mAuthorities) {
Boolean auto = mMasterSyncAutomatically.get(userId);
- return auto == null ? true : auto;
+ return auto == null ? mDefaultMasterSyncAutomatically : auto;
}
}
diff --git a/core/java/android/database/AbstractCursor.java b/core/java/android/database/AbstractCursor.java
index fb04817..e7ff92d 100644
--- a/core/java/android/database/AbstractCursor.java
+++ b/core/java/android/database/AbstractCursor.java
@@ -424,6 +424,9 @@ public abstract class AbstractCursor implements CrossProcessCursor {
if (mSelfObserver != null && mSelfObserverRegistered == true) {
mContentResolver.unregisterContentObserver(mSelfObserver);
}
+ try {
+ if (!mClosed) close();
+ } catch(Exception e) { }
}
/**
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 4d9077f..829620b 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -26,6 +26,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
+import android.text.TextUtils;
import android.view.Surface;
import android.view.SurfaceHolder;
@@ -34,7 +35,6 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-import java.util.StringTokenizer;
import java.util.concurrent.locks.ReentrantLock;
/**
@@ -1905,7 +1905,7 @@ public class Camera {
private HashMap<String, String> mMap;
private Parameters() {
- mMap = new HashMap<String, String>();
+ mMap = new HashMap<String, String>(64);
}
/**
@@ -1929,7 +1929,7 @@ public class Camera {
* semi-colon delimited key-value pairs
*/
public String flatten() {
- StringBuilder flattened = new StringBuilder();
+ StringBuilder flattened = new StringBuilder(128);
for (String k : mMap.keySet()) {
flattened.append(k);
flattened.append("=");
@@ -1952,9 +1952,9 @@ public class Camera {
public void unflatten(String flattened) {
mMap.clear();
- StringTokenizer tokenizer = new StringTokenizer(flattened, ";");
- while (tokenizer.hasMoreElements()) {
- String kv = tokenizer.nextToken();
+ TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter(';');
+ splitter.setString(flattened);
+ for (String kv : splitter) {
int pos = kv.indexOf('=');
if (pos == -1) {
continue;
@@ -3488,11 +3488,11 @@ public class Camera {
private ArrayList<String> split(String str) {
if (str == null) return null;
- // Use StringTokenizer because it is faster than split.
- StringTokenizer tokenizer = new StringTokenizer(str, ",");
+ TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
+ splitter.setString(str);
ArrayList<String> substrings = new ArrayList<String>();
- while (tokenizer.hasMoreElements()) {
- substrings.add(tokenizer.nextToken());
+ for (String s : splitter) {
+ substrings.add(s);
}
return substrings;
}
@@ -3502,11 +3502,11 @@ public class Camera {
private ArrayList<Integer> splitInt(String str) {
if (str == null) return null;
- StringTokenizer tokenizer = new StringTokenizer(str, ",");
+ TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
+ splitter.setString(str);
ArrayList<Integer> substrings = new ArrayList<Integer>();
- while (tokenizer.hasMoreElements()) {
- String token = tokenizer.nextToken();
- substrings.add(Integer.parseInt(token));
+ for (String s : splitter) {
+ substrings.add(Integer.parseInt(s));
}
if (substrings.size() == 0) return null;
return substrings;
@@ -3515,11 +3515,11 @@ public class Camera {
private void splitInt(String str, int[] output) {
if (str == null) return;
- StringTokenizer tokenizer = new StringTokenizer(str, ",");
+ TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
+ splitter.setString(str);
int index = 0;
- while (tokenizer.hasMoreElements()) {
- String token = tokenizer.nextToken();
- output[index++] = Integer.parseInt(token);
+ for (String s : splitter) {
+ output[index++] = Integer.parseInt(s);
}
}
@@ -3527,11 +3527,11 @@ public class Camera {
private void splitFloat(String str, float[] output) {
if (str == null) return;
- StringTokenizer tokenizer = new StringTokenizer(str, ",");
+ TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
+ splitter.setString(str);
int index = 0;
- while (tokenizer.hasMoreElements()) {
- String token = tokenizer.nextToken();
- output[index++] = Float.parseFloat(token);
+ for (String s : splitter) {
+ output[index++] = Float.parseFloat(s);
}
}
@@ -3558,10 +3558,11 @@ public class Camera {
private ArrayList<Size> splitSize(String str) {
if (str == null) return null;
- StringTokenizer tokenizer = new StringTokenizer(str, ",");
+ TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
+ splitter.setString(str);
ArrayList<Size> sizeList = new ArrayList<Size>();
- while (tokenizer.hasMoreElements()) {
- Size size = strToSize(tokenizer.nextToken());
+ for (String s : splitter) {
+ Size size = strToSize(s);
if (size != null) sizeList.add(size);
}
if (sizeList.size() == 0) return null;
diff --git a/core/java/android/net/DhcpStateMachine.java b/core/java/android/net/DhcpStateMachine.java
index 397a12a..cc3e34f 100644
--- a/core/java/android/net/DhcpStateMachine.java
+++ b/core/java/android/net/DhcpStateMachine.java
@@ -163,8 +163,21 @@ public class DhcpStateMachine extends StateMachine {
mRegisteredForPreDhcpNotification = true;
}
+ /**
+ * Quit the DhcpStateMachine.
+ *
+ * @hide
+ */
+ public void doQuit() {
+ quit();
+ }
+
class DefaultState extends State {
@Override
+ public void exit() {
+ mContext.unregisterReceiver(mBroadcastReceiver);
+ }
+ @Override
public boolean processMessage(Message message) {
if (DBG) Log.d(TAG, getName() + message.toString() + "\n");
switch (message.what) {
@@ -172,10 +185,6 @@ public class DhcpStateMachine extends StateMachine {
Log.e(TAG, "Error! Failed to handle a DHCP renewal on " + mInterfaceName);
mDhcpRenewWakeLock.release();
break;
- case SM_QUIT_CMD:
- mContext.unregisterReceiver(mBroadcastReceiver);
- //let parent kill the state machine
- return NOT_HANDLED;
default:
Log.e(TAG, "Error! unhandled message " + message);
break;
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java
index 28bd289..0cc78c9 100644
--- a/core/java/android/net/EthernetDataTracker.java
+++ b/core/java/android/net/EthernetDataTracker.java
@@ -223,7 +223,7 @@ public class EthernetDataTracker implements NetworkStateTracker {
mIface = iface;
mNMService.setInterfaceUp(iface);
InterfaceConfiguration config = mNMService.getInterfaceConfig(iface);
- mLinkUp = config.isActive();
+ mLinkUp = config.hasFlag("up");
if (config != null && mHwAddr == null) {
mHwAddr = config.getHardwareAddress();
if (mHwAddr != null) {
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java
index 57f8d48..d59fa6a 100644
--- a/core/java/android/net/MobileDataStateTracker.java
+++ b/core/java/android/net/MobileDataStateTracker.java
@@ -16,11 +16,6 @@
package android.net;
-import static com.android.internal.telephony.DataConnectionTracker.CMD_SET_POLICY_DATA_ENABLE;
-import static com.android.internal.telephony.DataConnectionTracker.CMD_SET_USER_DATA_ENABLE;
-import static com.android.internal.telephony.DataConnectionTracker.DISABLED;
-import static com.android.internal.telephony.DataConnectionTracker.ENABLED;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -37,9 +32,9 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Slog;
-import com.android.internal.telephony.DataConnectionTracker;
+import com.android.internal.telephony.DctConstants;
import com.android.internal.telephony.ITelephony;
-import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.AsyncChannel;
@@ -59,7 +54,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
private static final boolean DBG = false;
private static final boolean VDBG = false;
- private Phone.DataState mMobileDataState;
+ private PhoneConstants.DataState mMobileDataState;
private ITelephony mPhoneService;
private String mApnType;
@@ -108,10 +103,10 @@ public class MobileDataStateTracker implements NetworkStateTracker {
IntentFilter filter = new IntentFilter();
filter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
- filter.addAction(DataConnectionTracker.ACTION_DATA_CONNECTION_TRACKER_MESSENGER);
+ filter.addAction(DctConstants.ACTION_DATA_CONNECTION_TRACKER_MESSENGER);
mContext.registerReceiver(new MobileDataStateReceiver(), filter);
- mMobileDataState = Phone.DataState.DISCONNECTED;
+ mMobileDataState = PhoneConstants.DataState.DISCONNECTED;
}
static class MdstHandler extends Handler {
@@ -180,7 +175,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(TelephonyIntents.
ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
- String apnType = intent.getStringExtra(Phone.DATA_APN_TYPE_KEY);
+ String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY);
if (VDBG) {
log(String.format("Broadcast received: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED"
+ "mApnType=%s %s received apnType=%s", mApnType,
@@ -189,20 +184,29 @@ public class MobileDataStateTracker implements NetworkStateTracker {
if (!TextUtils.equals(apnType, mApnType)) {
return;
}
- mNetworkInfo.setSubtype(TelephonyManager.getDefault().getNetworkType(),
- TelephonyManager.getDefault().getNetworkTypeName());
- Phone.DataState state = Enum.valueOf(Phone.DataState.class,
- intent.getStringExtra(Phone.STATE_KEY));
- String reason = intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY);
- String apnName = intent.getStringExtra(Phone.DATA_APN_KEY);
- mNetworkInfo.setRoaming(intent.getBooleanExtra(Phone.DATA_NETWORK_ROAMING_KEY,
- false));
+
+ int oldSubtype = mNetworkInfo.getSubtype();
+ int newSubType = TelephonyManager.getDefault().getNetworkType();
+ String subTypeName = TelephonyManager.getDefault().getNetworkTypeName();
+ mNetworkInfo.setSubtype(newSubType, subTypeName);
+ if (newSubType != oldSubtype && mNetworkInfo.isConnected()) {
+ Message msg = mTarget.obtainMessage(EVENT_NETWORK_SUBTYPE_CHANGED,
+ oldSubtype, 0, mNetworkInfo);
+ msg.sendToTarget();
+ }
+
+ PhoneConstants.DataState state = Enum.valueOf(PhoneConstants.DataState.class,
+ intent.getStringExtra(PhoneConstants.STATE_KEY));
+ String reason = intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY);
+ String apnName = intent.getStringExtra(PhoneConstants.DATA_APN_KEY);
+ mNetworkInfo.setRoaming(intent.getBooleanExtra(
+ PhoneConstants.DATA_NETWORK_ROAMING_KEY, false));
if (VDBG) {
log(mApnType + " setting isAvailable to " +
- intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,false));
+ intent.getBooleanExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY,false));
}
- mNetworkInfo.setIsAvailable(!intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,
- false));
+ mNetworkInfo.setIsAvailable(!intent.getBooleanExtra(
+ PhoneConstants.NETWORK_UNAVAILABLE_KEY, false));
if (DBG) {
log("Received state=" + state + ", old=" + mMobileDataState +
@@ -232,13 +236,13 @@ public class MobileDataStateTracker implements NetworkStateTracker {
break;
case CONNECTED:
mLinkProperties = intent.getParcelableExtra(
- Phone.DATA_LINK_PROPERTIES_KEY);
+ PhoneConstants.DATA_LINK_PROPERTIES_KEY);
if (mLinkProperties == null) {
loge("CONNECTED event did not supply link properties.");
mLinkProperties = new LinkProperties();
}
mLinkCapabilities = intent.getParcelableExtra(
- Phone.DATA_LINK_CAPABILITIES_KEY);
+ PhoneConstants.DATA_LINK_CAPABILITIES_KEY);
if (mLinkCapabilities == null) {
loge("CONNECTED event did not supply link capabilities.");
mLinkCapabilities = new LinkCapabilities();
@@ -248,8 +252,9 @@ public class MobileDataStateTracker implements NetworkStateTracker {
}
} else {
// There was no state change. Check if LinkProperties has been updated.
- if (TextUtils.equals(reason, Phone.REASON_LINK_PROPERTIES_CHANGED)) {
- mLinkProperties = intent.getParcelableExtra(Phone.DATA_LINK_PROPERTIES_KEY);
+ if (TextUtils.equals(reason, PhoneConstants.REASON_LINK_PROPERTIES_CHANGED)) {
+ mLinkProperties = intent.getParcelableExtra(
+ PhoneConstants.DATA_LINK_PROPERTIES_KEY);
if (mLinkProperties == null) {
loge("No link property in LINK_PROPERTIES change event.");
mLinkProperties = new LinkProperties();
@@ -264,7 +269,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
}
} else if (intent.getAction().
equals(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED)) {
- String apnType = intent.getStringExtra(Phone.DATA_APN_TYPE_KEY);
+ String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY);
if (!TextUtils.equals(apnType, mApnType)) {
if (DBG) {
log(String.format(
@@ -273,17 +278,18 @@ public class MobileDataStateTracker implements NetworkStateTracker {
}
return;
}
- String reason = intent.getStringExtra(Phone.FAILURE_REASON_KEY);
- String apnName = intent.getStringExtra(Phone.DATA_APN_KEY);
+ String reason = intent.getStringExtra(PhoneConstants.FAILURE_REASON_KEY);
+ String apnName = intent.getStringExtra(PhoneConstants.DATA_APN_KEY);
if (DBG) {
log("Received " + intent.getAction() +
" broadcast" + reason == null ? "" : "(" + reason + ")");
}
setDetailedState(DetailedState.FAILED, reason, apnName);
- } else if (intent.getAction().
- equals(DataConnectionTracker.ACTION_DATA_CONNECTION_TRACKER_MESSENGER)) {
+ } else if (intent.getAction().equals(DctConstants
+ .ACTION_DATA_CONNECTION_TRACKER_MESSENGER)) {
if (VDBG) log(mApnType + " got ACTION_DATA_CONNECTION_TRACKER_MESSENGER");
- mMessenger = intent.getParcelableExtra(DataConnectionTracker.EXTRA_MESSENGER);
+ mMessenger =
+ intent.getParcelableExtra(DctConstants.EXTRA_MESSENGER);
AsyncChannel ac = new AsyncChannel();
ac.connect(mContext, MobileDataStateTracker.this.mHandler, mMessenger);
} else {
@@ -332,6 +338,9 @@ public class MobileDataStateTracker implements NetworkStateTracker {
case TelephonyManager.NETWORK_TYPE_HSPA:
networkTypeStr = "hspa";
break;
+ case TelephonyManager.NETWORK_TYPE_HSPAP:
+ networkTypeStr = "hspap";
+ break;
case TelephonyManager.NETWORK_TYPE_CDMA:
networkTypeStr = "cdma";
break;
@@ -369,7 +378,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
*/
public boolean teardown() {
setTeardownRequested(true);
- return (setEnableApn(mApnType, false) != Phone.APN_REQUEST_FAILED);
+ return (setEnableApn(mApnType, false) != PhoneConstants.APN_REQUEST_FAILED);
}
/**
@@ -418,17 +427,17 @@ public class MobileDataStateTracker implements NetworkStateTracker {
boolean retValue = false; //connected or expect to be?
setTeardownRequested(false);
switch (setEnableApn(mApnType, true)) {
- case Phone.APN_ALREADY_ACTIVE:
+ case PhoneConstants.APN_ALREADY_ACTIVE:
// need to set self to CONNECTING so the below message is handled.
retValue = true;
break;
- case Phone.APN_REQUEST_STARTED:
+ case PhoneConstants.APN_REQUEST_STARTED:
// set IDLE here , avoid the following second FAILED not sent out
mNetworkInfo.setDetailedState(DetailedState.IDLE, null, null);
retValue = true;
break;
- case Phone.APN_REQUEST_FAILED:
- case Phone.APN_TYPE_NOT_AVAILABLE:
+ case PhoneConstants.APN_REQUEST_FAILED:
+ case PhoneConstants.APN_TYPE_NOT_AVAILABLE:
break;
default:
loge("Error in reconnect - unexpected response.");
@@ -470,7 +479,8 @@ public class MobileDataStateTracker implements NetworkStateTracker {
if (DBG) log("setUserDataEnable: E enabled=" + enabled);
final AsyncChannel channel = mDataConnectionTrackerAc;
if (channel != null) {
- channel.sendMessage(CMD_SET_USER_DATA_ENABLE, enabled ? ENABLED : DISABLED);
+ channel.sendMessage(DctConstants.CMD_SET_USER_DATA_ENABLE,
+ enabled ? DctConstants.ENABLED : DctConstants.DISABLED);
mUserDataEnabled = enabled;
}
if (VDBG) log("setUserDataEnable: X enabled=" + enabled);
@@ -481,7 +491,8 @@ public class MobileDataStateTracker implements NetworkStateTracker {
if (DBG) log("setPolicyDataEnable(enabled=" + enabled + ")");
final AsyncChannel channel = mDataConnectionTrackerAc;
if (channel != null) {
- channel.sendMessage(CMD_SET_POLICY_DATA_ENABLE, enabled ? ENABLED : DISABLED);
+ channel.sendMessage(DctConstants.CMD_SET_POLICY_DATA_ENABLE,
+ enabled ? DctConstants.ENABLED : DctConstants.DISABLED);
mPolicyDataEnabled = enabled;
}
}
@@ -491,12 +502,12 @@ public class MobileDataStateTracker implements NetworkStateTracker {
* @param met
*/
public void setDependencyMet(boolean met) {
- Bundle bundle = Bundle.forPair(DataConnectionTracker.APN_TYPE_KEY, mApnType);
+ Bundle bundle = Bundle.forPair(DctConstants.APN_TYPE_KEY, mApnType);
try {
if (DBG) log("setDependencyMet: E met=" + met);
Message msg = Message.obtain();
- msg.what = DataConnectionTracker.CMD_SET_DEPENDENCY_MET;
- msg.arg1 = (met ? DataConnectionTracker.ENABLED : DataConnectionTracker.DISABLED);
+ msg.what = DctConstants.CMD_SET_DEPENDENCY_MET;
+ msg.arg1 = (met ? DctConstants.ENABLED : DctConstants.DISABLED);
msg.setData(bundle);
mDataConnectionTrackerAc.sendMessage(msg);
if (VDBG) log("setDependencyMet: X met=" + met);
@@ -546,27 +557,27 @@ public class MobileDataStateTracker implements NetworkStateTracker {
}
loge("Could not " + (enable ? "enable" : "disable") + " APN type \"" + apnType + "\"");
- return Phone.APN_REQUEST_FAILED;
+ return PhoneConstants.APN_REQUEST_FAILED;
}
public static String networkTypeToApnType(int netType) {
switch(netType) {
case ConnectivityManager.TYPE_MOBILE:
- return Phone.APN_TYPE_DEFAULT; // TODO - use just one of these
+ return PhoneConstants.APN_TYPE_DEFAULT; // TODO - use just one of these
case ConnectivityManager.TYPE_MOBILE_MMS:
- return Phone.APN_TYPE_MMS;
+ return PhoneConstants.APN_TYPE_MMS;
case ConnectivityManager.TYPE_MOBILE_SUPL:
- return Phone.APN_TYPE_SUPL;
+ return PhoneConstants.APN_TYPE_SUPL;
case ConnectivityManager.TYPE_MOBILE_DUN:
- return Phone.APN_TYPE_DUN;
+ return PhoneConstants.APN_TYPE_DUN;
case ConnectivityManager.TYPE_MOBILE_HIPRI:
- return Phone.APN_TYPE_HIPRI;
+ return PhoneConstants.APN_TYPE_HIPRI;
case ConnectivityManager.TYPE_MOBILE_FOTA:
- return Phone.APN_TYPE_FOTA;
+ return PhoneConstants.APN_TYPE_FOTA;
case ConnectivityManager.TYPE_MOBILE_IMS:
- return Phone.APN_TYPE_IMS;
+ return PhoneConstants.APN_TYPE_IMS;
case ConnectivityManager.TYPE_MOBILE_CBS:
- return Phone.APN_TYPE_CBS;
+ return PhoneConstants.APN_TYPE_CBS;
default:
sloge("Error mapping networkType " + netType + " to apnType.");
return null;
diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java
index 7df0193..0d6dcd6 100644
--- a/core/java/android/net/NetworkStateTracker.java
+++ b/core/java/android/net/NetworkStateTracker.java
@@ -69,6 +69,12 @@ public interface NetworkStateTracker {
public static final int EVENT_RESTORE_DEFAULT_NETWORK = 6;
/**
+ * msg.what = EVENT_NETWORK_SUBTYPE_CHANGED
+ * msg.obj = NetworkInfo object
+ */
+ public static final int EVENT_NETWORK_SUBTYPE_CHANGED = 7;
+
+ /**
* -------------------------------------------------------------
* Control Interface
* -------------------------------------------------------------
diff --git a/core/java/android/net/VpnService.java b/core/java/android/net/VpnService.java
index fb5263d..65d3f2b 100644
--- a/core/java/android/net/VpnService.java
+++ b/core/java/android/net/VpnService.java
@@ -329,7 +329,7 @@ public class VpnService extends Service {
throw new IllegalArgumentException("Bad address");
}
- mAddresses.append(String.format(" %s/%d", address.getHostAddress(), prefixLength));
+ mAddresses.append(' ' + address.getHostAddress() + '/' + prefixLength);
return this;
}
diff --git a/core/java/android/net/arp/ArpPeer.java b/core/java/android/net/arp/ArpPeer.java
index 8e666bc..6ba1e7c 100644
--- a/core/java/android/net/arp/ArpPeer.java
+++ b/core/java/android/net/arp/ArpPeer.java
@@ -53,9 +53,11 @@ public class ArpPeer {
mInterfaceName = interfaceName;
mMyAddr = myAddr;
- for (int i = 0; i < MAC_ADDR_LENGTH; i++) {
- mMyMac[i] = (byte) Integer.parseInt(mac.substring(
- i*3, (i*3) + 2), 16);
+ if (mac != null) {
+ for (int i = 0; i < MAC_ADDR_LENGTH; i++) {
+ mMyMac[i] = (byte) Integer.parseInt(mac.substring(
+ i*3, (i*3) + 2), 16);
+ }
}
if (myAddr instanceof Inet6Address || peer instanceof Inet6Address) {
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index 6c1445d..0941d71 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -28,9 +28,6 @@ import java.util.regex.Pattern;
import java.util.zip.CRC32;
import java.util.zip.CheckedInputStream;
-import libcore.io.Os;
-import libcore.io.StructStat;
-
/**
* Tools for managing files. Not for public consumption.
* @hide
@@ -50,60 +47,12 @@ public class FileUtils {
public static final int S_IROTH = 00004;
public static final int S_IWOTH = 00002;
public static final int S_IXOTH = 00001;
-
-
- /**
- * File status information. This class maps directly to the POSIX stat structure.
- * @deprecated use {@link StructStat} instead.
- * @hide
- */
- @Deprecated
- public static final class FileStatus {
- public int dev;
- public int ino;
- public int mode;
- public int nlink;
- public int uid;
- public int gid;
- public int rdev;
- public long size;
- public int blksize;
- public long blocks;
- public long atime;
- public long mtime;
- public long ctime;
- }
-
- /**
- * Get the status for the given path. This is equivalent to the POSIX stat(2) system call.
- * @param path The path of the file to be stat'd.
- * @param status Optional argument to fill in. It will only fill in the status if the file
- * exists.
- * @return true if the file exists and false if it does not exist. If you do not have
- * permission to stat the file, then this method will return false.
- * @deprecated use {@link Os#stat(String)} instead.
- */
- @Deprecated
- public static boolean getFileStatus(String path, FileStatus status) {
- StrictMode.noteDiskRead();
- return getFileStatusNative(path, status);
- }
-
- private static native boolean getFileStatusNative(String path, FileStatus status);
/** Regular expression for safe filenames: no spaces or metacharacters */
private static final Pattern SAFE_FILENAME_PATTERN = Pattern.compile("[\\w%+,./=_-]+");
public static native int setPermissions(String file, int mode, int uid, int gid);
- /**
- * @deprecated use {@link Os#stat(String)} instead.
- */
- @Deprecated
- public static native int getPermissions(String file, int[] outPermissions);
-
- public static native int setUMask(int mask);
-
/** returns the FAT file system volume ID for the volume mounted
* at the given mount point, or -1 for failure
* @param mountPoint point for FAT volume
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index 8eaeb1d..6ab4dc1 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -359,6 +359,7 @@ public class Process {
* @param gids Additional group-ids associated with the process.
* @param debugFlags Additional flags.
* @param targetSdkVersion The target SDK version for the app.
+ * @param seInfo null-ok SE Android information for the new process.
* @param zygoteArgs Additional arguments to supply to the zygote process.
*
* @return An object that describes the result of the attempt to start the process.
@@ -370,10 +371,11 @@ public class Process {
final String niceName,
int uid, int gid, int[] gids,
int debugFlags, int targetSdkVersion,
+ String seInfo,
String[] zygoteArgs) {
try {
return startViaZygote(processClass, niceName, uid, gid, gids,
- debugFlags, targetSdkVersion, zygoteArgs);
+ debugFlags, targetSdkVersion, seInfo, zygoteArgs);
} catch (ZygoteStartFailedEx ex) {
Log.e(LOG_TAG,
"Starting VM process through Zygote failed");
@@ -536,6 +538,7 @@ public class Process {
* new process should setgroup() to.
* @param debugFlags Additional flags.
* @param targetSdkVersion The target SDK version for the app.
+ * @param seInfo null-ok SE Android information for the new process.
* @param extraArgs Additional arguments to supply to the zygote process.
* @return An object that describes the result of the attempt to start the process.
* @throws ZygoteStartFailedEx if process start failed for any reason
@@ -545,6 +548,7 @@ public class Process {
final int uid, final int gid,
final int[] gids,
int debugFlags, int targetSdkVersion,
+ String seInfo,
String[] extraArgs)
throws ZygoteStartFailedEx {
synchronized(Process.class) {
@@ -595,6 +599,10 @@ public class Process {
argsForZygote.add("--nice-name=" + niceName);
}
+ if (seInfo != null) {
+ argsForZygote.add("--seinfo=" + seInfo);
+ }
+
argsForZygote.add(processClass);
if (extraArgs != null) {
diff --git a/core/java/android/os/SELinux.java b/core/java/android/os/SELinux.java
new file mode 100644
index 0000000..c05a974
--- /dev/null
+++ b/core/java/android/os/SELinux.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2012 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.os;
+
+import android.util.Slog;
+
+import java.io.IOException;
+import java.io.File;
+import java.io.FileDescriptor;
+
+/**
+ * This class provides access to the centralized jni bindings for
+ * SELinux interaction.
+ * {@hide}
+ */
+public class SELinux {
+
+ private static final String TAG = "SELinux";
+
+ /**
+ * Determine whether SELinux is disabled or enabled.
+ * @return a boolean indicating whether SELinux is enabled.
+ */
+ public static final native boolean isSELinuxEnabled();
+
+ /**
+ * Determine whether SELinux is permissive or enforcing.
+ * @return a boolean indicating whether SELinux is enforcing.
+ */
+ public static final native boolean isSELinuxEnforced();
+
+ /**
+ * Set whether SELinux is permissive or enforcing.
+ * @param boolean representing whether to set SELinux to enforcing
+ * @return a boolean representing whether the desired mode was set
+ */
+ public static final native boolean setSELinuxEnforce(boolean value);
+
+ /**
+ * Sets the security context for newly created file objects.
+ * @param context a security context given as a String.
+ * @return a boolean indicating whether the operation succeeded.
+ */
+ public static final native boolean setFSCreateContext(String context);
+
+ /**
+ * Change the security context of an existing file object.
+ * @param path representing the path of file object to relabel.
+ * @param con new security context given as a String.
+ * @return a boolean indicating whether the operation succeeded.
+ */
+ public static final native boolean setFileContext(String path, String context);
+
+ /**
+ * Get the security context of a file object.
+ * @param path the pathname of the file object.
+ * @return a security context given as a String.
+ */
+ public static final native String getFileContext(String path);
+
+ /**
+ * Get the security context of a peer socket.
+ * @param fd FileDescriptor class of the peer socket.
+ * @return a String representing the peer socket security context.
+ */
+ public static final native String getPeerContext(FileDescriptor fd);
+
+ /**
+ * Gets the security context of the current process.
+ * @return a String representing the security context of the current process.
+ */
+ public static final native String getContext();
+
+ /**
+ * Gets the security context of a given process id.
+ * Use of this function is discouraged for Binder transactions.
+ * Use Binder.getCallingSecctx() instead.
+ * @param pid an int representing the process id to check.
+ * @return a String representing the security context of the given pid.
+ */
+ public static final native String getPidContext(int pid);
+
+ /**
+ * Gets a list of the SELinux boolean names.
+ * @return an array of strings containing the SELinux boolean names.
+ */
+ public static final native String[] getBooleanNames();
+
+ /**
+ * Gets the value for the given SELinux boolean name.
+ * @param String The name of the SELinux boolean.
+ * @return a boolean indicating whether the SELinux boolean is set.
+ */
+ public static final native boolean getBooleanValue(String name);
+
+ /**
+ * Sets the value for the given SELinux boolean name.
+ * @param String The name of the SELinux boolean.
+ * @param Boolean The new value of the SELinux boolean.
+ * @return a boolean indicating whether or not the operation succeeded.
+ */
+ public static final native boolean setBooleanValue(String name, boolean value);
+
+ /**
+ * Check permissions between two security contexts.
+ * @param scon The source or subject security context.
+ * @param tcon The target or object security context.
+ * @param tclass The object security class name.
+ * @param perm The permission name.
+ * @return a boolean indicating whether permission was granted.
+ */
+ public static final native boolean checkSELinuxAccess(String scon, String tcon, String tclass, String perm);
+
+ /**
+ * Restores a file to its default SELinux security context.
+ * If the system is not compiled with SELinux, then {@code true}
+ * is automatically returned.
+ * If SELinux is compiled in, but disabled, then {@code true} is
+ * returned.
+ *
+ * @param pathname The pathname of the file to be relabeled.
+ * @return a boolean indicating whether the relabeling succeeded.
+ * @exception NullPointerException if the pathname is a null object.
+ */
+ public static boolean restorecon(String pathname) throws NullPointerException {
+ if (pathname == null) { throw new NullPointerException(); }
+ return native_restorecon(pathname);
+ }
+
+ /**
+ * Restores a file to its default SELinux security context.
+ * If the system is not compiled with SELinux, then {@code true}
+ * is automatically returned.
+ * If SELinux is compiled in, but disabled, then {@code true} is
+ * returned.
+ *
+ * @param pathname The pathname of the file to be relabeled.
+ * @return a boolean indicating whether the relabeling succeeded.
+ */
+ private static native boolean native_restorecon(String pathname);
+
+ /**
+ * Restores a file to its default SELinux security context.
+ * If the system is not compiled with SELinux, then {@code true}
+ * is automatically returned.
+ * If SELinux is compiled in, but disabled, then {@code true} is
+ * returned.
+ *
+ * @param file The File object representing the path to be relabeled.
+ * @return a boolean indicating whether the relabeling succeeded.
+ * @exception NullPointerException if the file is a null object.
+ */
+ public static boolean restorecon(File file) throws NullPointerException {
+ try {
+ return native_restorecon(file.getCanonicalPath());
+ } catch (IOException e) {
+ Slog.e(TAG, "Error getting canonical path. Restorecon failed for " +
+ file.getPath(), e);
+ return false;
+ }
+ }
+}
diff --git a/core/java/android/os/StatFs.java b/core/java/android/os/StatFs.java
index 912bfdf..ca7fdba 100644
--- a/core/java/android/os/StatFs.java
+++ b/core/java/android/os/StatFs.java
@@ -16,59 +16,77 @@
package android.os;
+import libcore.io.ErrnoException;
+import libcore.io.Libcore;
+import libcore.io.StructStatFs;
+
/**
- * Retrieve overall information about the space on a filesystem. This is a
- * Wrapper for Unix statfs().
+ * Retrieve overall information about the space on a filesystem. This is a
+ * wrapper for Unix statfs().
*/
public class StatFs {
+ private StructStatFs mStat;
+
/**
- * Construct a new StatFs for looking at the stats of the
- * filesystem at <var>path</var>. Upon construction, the stat of
- * the file system will be performed, and the values retrieved available
- * from the methods on this class.
- *
- * @param path A path in the desired file system to state.
+ * Construct a new StatFs for looking at the stats of the filesystem at
+ * {@code path}. Upon construction, the stat of the file system will be
+ * performed, and the values retrieved available from the methods on this
+ * class.
+ *
+ * @param path path in the desired file system to stat.
*/
- public StatFs(String path) { native_setup(path); }
-
+ public StatFs(String path) {
+ mStat = doStat(path);
+ }
+
+ private static StructStatFs doStat(String path) {
+ try {
+ return Libcore.os.statfs(path);
+ } catch (ErrnoException e) {
+ throw new IllegalArgumentException("Invalid path: " + path, e);
+ }
+ }
+
/**
- * Perform a restat of the file system referenced by this object. This
- * is the same as re-constructing the object with the same file system
- * path, and the new stat values are available upon return.
+ * Perform a restat of the file system referenced by this object. This is
+ * the same as re-constructing the object with the same file system path,
+ * and the new stat values are available upon return.
*/
- public void restat(String path) { native_restat(path); }
-
- @Override
- protected void finalize() { native_finalize(); }
+ public void restat(String path) {
+ mStat = doStat(path);
+ }
/**
- * The size, in bytes, of a block on the file system. This corresponds
- * to the Unix statfs.f_bsize field.
+ * The size, in bytes, of a block on the file system. This corresponds to
+ * the Unix {@code statfs.f_bsize} field.
*/
- public native int getBlockSize();
+ public int getBlockSize() {
+ return (int) mStat.f_bsize;
+ }
/**
- * The total number of blocks on the file system. This corresponds
- * to the Unix statfs.f_blocks field.
+ * The total number of blocks on the file system. This corresponds to the
+ * Unix {@code statfs.f_blocks} field.
*/
- public native int getBlockCount();
+ public int getBlockCount() {
+ return (int) mStat.f_blocks;
+ }
/**
* The total number of blocks that are free on the file system, including
- * reserved blocks (that are not available to normal applications). This
- * corresponds to the Unix statfs.f_bfree field. Most applications will
- * want to use {@link #getAvailableBlocks()} instead.
+ * reserved blocks (that are not available to normal applications). This
+ * corresponds to the Unix {@code statfs.f_bfree} field. Most applications
+ * will want to use {@link #getAvailableBlocks()} instead.
*/
- public native int getFreeBlocks();
+ public int getFreeBlocks() {
+ return (int) mStat.f_bfree;
+ }
/**
* The number of blocks that are free on the file system and available to
- * applications. This corresponds to the Unix statfs.f_bavail field.
+ * applications. This corresponds to the Unix {@code statfs.f_bavail} field.
*/
- public native int getAvailableBlocks();
-
- private int mNativeContext;
- private native void native_restat(String path);
- private native void native_setup(String path);
- private native void native_finalize();
+ public int getAvailableBlocks() {
+ return (int) mStat.f_bavail;
+ }
}
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index ce213fb..f682abe 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -407,17 +407,17 @@ public final class StrictMode {
}
/**
- * Enable detection of disk reads.
+ * Enable detection of slow calls.
*/
public Builder detectCustomSlowCalls() {
return enable(DETECT_CUSTOM);
}
/**
- * Enable detection of disk reads.
+ * Disable detection of slow calls.
*/
public Builder permitCustomSlowCalls() {
- return enable(DETECT_CUSTOM);
+ return disable(DETECT_CUSTOM);
}
/**
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index cb6c1dc..8a20a6e 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -56,7 +56,7 @@ public class StorageManager
/*
* Our internal MountService binder reference
*/
- private IMountService mMountService;
+ final private IMountService mMountService;
/*
* The looper target for callbacks
@@ -304,8 +304,6 @@ public class StorageManager
return;
}
mTgtLooper = tgtLooper;
- mBinderListener = new MountServiceBinderListener();
- mMountService.registerListener(mBinderListener);
}
@@ -322,6 +320,15 @@ public class StorageManager
}
synchronized (mListeners) {
+ if (mBinderListener == null ) {
+ try {
+ mBinderListener = new MountServiceBinderListener();
+ mMountService.registerListener(mBinderListener);
+ } catch (RemoteException rex) {
+ Log.e(TAG, "Register mBinderListener failed");
+ return;
+ }
+ }
mListeners.add(new ListenerDelegate(listener));
}
}
@@ -347,7 +354,15 @@ public class StorageManager
break;
}
}
- }
+ if (mListeners.size() == 0 && mBinderListener != null) {
+ try {
+ mMountService.unregisterListener(mBinderListener);
+ } catch (RemoteException rex) {
+ Log.e(TAG, "Unregister mBinderListener failed");
+ return;
+ }
+ }
+ }
}
/**
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index 7824724..22b68bc 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -18,7 +18,7 @@
package android.provider;
import com.android.internal.telephony.CallerInfo;
-import com.android.internal.telephony.Connection;
+import com.android.internal.telephony.PhoneConstants;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -267,14 +267,14 @@ public class CallLog {
// If this is a private number then set the number to Private, otherwise check
// if the number field is empty and set the number to Unavailable
- if (presentation == Connection.PRESENTATION_RESTRICTED) {
+ if (presentation == PhoneConstants.PRESENTATION_RESTRICTED) {
number = CallerInfo.PRIVATE_NUMBER;
if (ci != null) ci.name = "";
- } else if (presentation == Connection.PRESENTATION_PAYPHONE) {
+ } else if (presentation == PhoneConstants.PRESENTATION_PAYPHONE) {
number = CallerInfo.PAYPHONE_NUMBER;
if (ci != null) ci.name = "";
} else if (TextUtils.isEmpty(number)
- || presentation == Connection.PRESENTATION_UNKNOWN) {
+ || presentation == PhoneConstants.PRESENTATION_UNKNOWN) {
number = CallerInfo.UNKNOWN_NUMBER;
if (ci != null) ci.name = "";
}
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 8e123ac..e7b0579 100644..100755
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -8362,7 +8362,7 @@ public final class ContactsContract {
// Line contains the query string - now search for it at the start of tokens.
List<String> lineTokens = new ArrayList<String>();
List<Integer> tokenOffsets = new ArrayList<Integer>();
- split(contentLine.trim(), lineTokens, tokenOffsets);
+ split(contentLine, lineTokens, tokenOffsets);
// As we find matches against the query, we'll populate this list with the marked
// (or unchanged) tokens.
diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java
deleted file mode 100755
index 19d8d5c..0000000
--- a/core/java/android/provider/Telephony.java
+++ /dev/null
@@ -1,2037 +0,0 @@
-/*
- * Copyright (C) 2006 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.provider;
-
-import android.annotation.SdkConstant;
-import android.annotation.SdkConstant.SdkConstantType;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.database.sqlite.SqliteWrapper;
-import android.net.Uri;
-import android.os.Environment;
-import android.telephony.SmsMessage;
-import android.text.TextUtils;
-import android.util.Log;
-import android.util.Patterns;
-
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * The Telephony provider contains data related to phone operation.
- *
- * @hide
- */
-public final class Telephony {
- private static final String TAG = "Telephony";
- private static final boolean DEBUG = true;
- private static final boolean LOCAL_LOGV = false;
-
- // Constructor
- public Telephony() {
- }
-
- /**
- * Base columns for tables that contain text based SMSs.
- */
- public interface TextBasedSmsColumns {
- /**
- * The type of the message
- * <P>Type: INTEGER</P>
- */
- public static final String TYPE = "type";
-
- public static final int MESSAGE_TYPE_ALL = 0;
- public static final int MESSAGE_TYPE_INBOX = 1;
- public static final int MESSAGE_TYPE_SENT = 2;
- public static final int MESSAGE_TYPE_DRAFT = 3;
- public static final int MESSAGE_TYPE_OUTBOX = 4;
- public static final int MESSAGE_TYPE_FAILED = 5; // for failed outgoing messages
- public static final int MESSAGE_TYPE_QUEUED = 6; // for messages to send later
-
-
- /**
- * The thread ID of the message
- * <P>Type: INTEGER</P>
- */
- public static final String THREAD_ID = "thread_id";
-
- /**
- * The address of the other party
- * <P>Type: TEXT</P>
- */
- public static final String ADDRESS = "address";
-
- /**
- * The person ID of the sender
- * <P>Type: INTEGER (long)</P>
- */
- public static final String PERSON_ID = "person";
-
- /**
- * The date the message was received
- * <P>Type: INTEGER (long)</P>
- */
- public static final String DATE = "date";
-
- /**
- * The date the message was sent
- * <P>Type: INTEGER (long)</P>
- */
- public static final String DATE_SENT = "date_sent";
-
- /**
- * Has the message been read
- * <P>Type: INTEGER (boolean)</P>
- */
- public static final String READ = "read";
-
- /**
- * Indicates whether this message has been seen by the user. The "seen" flag will be
- * used to figure out whether we need to throw up a statusbar notification or not.
- */
- public static final String SEEN = "seen";
-
- /**
- * The TP-Status value for the message, or -1 if no status has
- * been received
- */
- public static final String STATUS = "status";
-
- public static final int STATUS_NONE = -1;
- public static final int STATUS_COMPLETE = 0;
- public static final int STATUS_PENDING = 32;
- public static final int STATUS_FAILED = 64;
-
- /**
- * The subject of the message, if present
- * <P>Type: TEXT</P>
- */
- public static final String SUBJECT = "subject";
-
- /**
- * The body of the message
- * <P>Type: TEXT</P>
- */
- public static final String BODY = "body";
-
- /**
- * The id of the sender of the conversation, if present
- * <P>Type: INTEGER (reference to item in content://contacts/people)</P>
- */
- public static final String PERSON = "person";
-
- /**
- * The protocol identifier code
- * <P>Type: INTEGER</P>
- */
- public static final String PROTOCOL = "protocol";
-
- /**
- * Whether the <code>TP-Reply-Path</code> bit was set on this message
- * <P>Type: BOOLEAN</P>
- */
- public static final String REPLY_PATH_PRESENT = "reply_path_present";
-
- /**
- * The service center (SC) through which to send the message, if present
- * <P>Type: TEXT</P>
- */
- public static final String SERVICE_CENTER = "service_center";
-
- /**
- * Has the message been locked?
- * <P>Type: INTEGER (boolean)</P>
- */
- public static final String LOCKED = "locked";
-
- /**
- * Error code associated with sending or receiving this message
- * <P>Type: INTEGER</P>
- */
- public static final String ERROR_CODE = "error_code";
-
- /**
- * Meta data used externally.
- * <P>Type: TEXT</P>
- */
- public static final String META_DATA = "meta_data";
-}
-
- /**
- * Contains all text based SMS messages.
- */
- public static final class Sms implements BaseColumns, TextBasedSmsColumns {
- public static final Cursor query(ContentResolver cr, String[] projection) {
- return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
- }
-
- public static final Cursor query(ContentResolver cr, String[] projection,
- String where, String orderBy) {
- return cr.query(CONTENT_URI, projection, where,
- null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
- }
-
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the given URI.
- *
- * @param resolver the content resolver to use
- * @param uri the URI to add the message to
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @param read true if the message has been read, false if not
- * @param deliveryReport true if a delivery report was requested, false if not
- * @return the URI for the new message
- */
- public static Uri addMessageToUri(ContentResolver resolver,
- Uri uri, String address, String body, String subject,
- Long date, boolean read, boolean deliveryReport) {
- return addMessageToUri(resolver, uri, address, body, subject,
- date, read, deliveryReport, -1L);
- }
-
- /**
- * Add an SMS to the given URI with thread_id specified.
- *
- * @param resolver the content resolver to use
- * @param uri the URI to add the message to
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @param read true if the message has been read, false if not
- * @param deliveryReport true if a delivery report was requested, false if not
- * @param threadId the thread_id of the message
- * @return the URI for the new message
- */
- public static Uri addMessageToUri(ContentResolver resolver,
- Uri uri, String address, String body, String subject,
- Long date, boolean read, boolean deliveryReport, long threadId) {
- ContentValues values = new ContentValues(7);
-
- values.put(ADDRESS, address);
- if (date != null) {
- values.put(DATE, date);
- }
- values.put(READ, read ? Integer.valueOf(1) : Integer.valueOf(0));
- values.put(SUBJECT, subject);
- values.put(BODY, body);
- if (deliveryReport) {
- values.put(STATUS, STATUS_PENDING);
- }
- if (threadId != -1L) {
- values.put(THREAD_ID, threadId);
- }
- return resolver.insert(uri, values);
- }
-
- /**
- * Move a message to the given folder.
- *
- * @param context the context to use
- * @param uri the message to move
- * @param folder the folder to move to
- * @return true if the operation succeeded
- */
- public static boolean moveMessageToFolder(Context context,
- Uri uri, int folder, int error) {
- if (uri == null) {
- return false;
- }
-
- boolean markAsUnread = false;
- boolean markAsRead = false;
- switch(folder) {
- case MESSAGE_TYPE_INBOX:
- case MESSAGE_TYPE_DRAFT:
- break;
- case MESSAGE_TYPE_OUTBOX:
- case MESSAGE_TYPE_SENT:
- markAsRead = true;
- break;
- case MESSAGE_TYPE_FAILED:
- case MESSAGE_TYPE_QUEUED:
- markAsUnread = true;
- break;
- default:
- return false;
- }
-
- ContentValues values = new ContentValues(3);
-
- values.put(TYPE, folder);
- if (markAsUnread) {
- values.put(READ, Integer.valueOf(0));
- } else if (markAsRead) {
- values.put(READ, Integer.valueOf(1));
- }
- values.put(ERROR_CODE, error);
-
- return 1 == SqliteWrapper.update(context, context.getContentResolver(),
- uri, values, null, null);
- }
-
- /**
- * Returns true iff the folder (message type) identifies an
- * outgoing message.
- */
- public static boolean isOutgoingFolder(int messageType) {
- return (messageType == MESSAGE_TYPE_FAILED)
- || (messageType == MESSAGE_TYPE_OUTBOX)
- || (messageType == MESSAGE_TYPE_SENT)
- || (messageType == MESSAGE_TYPE_QUEUED);
- }
-
- /**
- * Contains all text based SMS messages in the SMS app's inbox.
- */
- public static final class Inbox implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/inbox");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the Draft box.
- *
- * @param resolver the content resolver to use
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @param read true if the message has been read, false if not
- * @return the URI for the new message
- */
- public static Uri addMessage(ContentResolver resolver,
- String address, String body, String subject, Long date,
- boolean read) {
- return addMessageToUri(resolver, CONTENT_URI, address, body,
- subject, date, read, false);
- }
- }
-
- /**
- * Contains all sent text based SMS messages in the SMS app's.
- */
- public static final class Sent implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/sent");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the Draft box.
- *
- * @param resolver the content resolver to use
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @return the URI for the new message
- */
- public static Uri addMessage(ContentResolver resolver,
- String address, String body, String subject, Long date) {
- return addMessageToUri(resolver, CONTENT_URI, address, body,
- subject, date, true, false);
- }
- }
-
- /**
- * Contains all sent text based SMS messages in the SMS app's.
- */
- public static final class Draft implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/draft");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the Draft box.
- *
- * @param resolver the content resolver to use
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @return the URI for the new message
- */
- public static Uri addMessage(ContentResolver resolver,
- String address, String body, String subject, Long date) {
- return addMessageToUri(resolver, CONTENT_URI, address, body,
- subject, date, true, false);
- }
-
- /**
- * Save over an existing draft message.
- *
- * @param resolver the content resolver to use
- * @param uri of existing message
- * @param body the new body for the draft message
- * @return true is successful, false otherwise
- */
- public static boolean saveMessage(ContentResolver resolver,
- Uri uri, String body) {
- ContentValues values = new ContentValues(2);
- values.put(BODY, body);
- values.put(DATE, System.currentTimeMillis());
- return resolver.update(uri, values, null, null) == 1;
- }
- }
-
- /**
- * Contains all pending outgoing text based SMS messages.
- */
- public static final class Outbox implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/outbox");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * Add an SMS to the Out box.
- *
- * @param resolver the content resolver to use
- * @param address the address of the sender
- * @param body the body of the message
- * @param subject the psuedo-subject of the message
- * @param date the timestamp for the message
- * @param deliveryReport whether a delivery report was requested for the message
- * @return the URI for the new message
- */
- public static Uri addMessage(ContentResolver resolver,
- String address, String body, String subject, Long date,
- boolean deliveryReport, long threadId) {
- return addMessageToUri(resolver, CONTENT_URI, address, body,
- subject, date, true, deliveryReport, threadId);
- }
- }
-
- /**
- * Contains all sent text-based SMS messages in the SMS app's.
- */
- public static final class Conversations
- implements BaseColumns, TextBasedSmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://sms/conversations");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * The first 45 characters of the body of the message
- * <P>Type: TEXT</P>
- */
- public static final String SNIPPET = "snippet";
-
- /**
- * The number of messages in the conversation
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_COUNT = "msg_count";
- }
-
- /**
- * Contains info about SMS related Intents that are broadcast.
- */
- public static final class Intents {
- /**
- * Set by BroadcastReceiver. Indicates the message was handled
- * successfully.
- */
- public static final int RESULT_SMS_HANDLED = 1;
-
- /**
- * Set by BroadcastReceiver. Indicates a generic error while
- * processing the message.
- */
- public static final int RESULT_SMS_GENERIC_ERROR = 2;
-
- /**
- * Set by BroadcastReceiver. Indicates insufficient memory to store
- * the message.
- */
- public static final int RESULT_SMS_OUT_OF_MEMORY = 3;
-
- /**
- * Set by BroadcastReceiver. Indicates the message, while
- * possibly valid, is of a format or encoding that is not
- * supported.
- */
- public static final int RESULT_SMS_UNSUPPORTED = 4;
-
- /**
- * Broadcast Action: A new text based SMS message has been received
- * by the device. The intent will have the following extra
- * values:</p>
- *
- * <ul>
- * <li><em>pdus</em> - An Object[] od byte[]s containing the PDUs
- * that make up the message.</li>
- * </ul>
- *
- * <p>The extra values can be extracted using
- * {@link #getMessagesFromIntent(Intent)}.</p>
- *
- * <p>If a BroadcastReceiver encounters an error while processing
- * this intent it should set the result code appropriately.</p>
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String SMS_RECEIVED_ACTION =
- "android.provider.Telephony.SMS_RECEIVED";
-
- /**
- * Broadcast Action: A new data based SMS message has been received
- * by the device. The intent will have the following extra
- * values:</p>
- *
- * <ul>
- * <li><em>pdus</em> - An Object[] of byte[]s containing the PDUs
- * that make up the message.</li>
- * </ul>
- *
- * <p>The extra values can be extracted using
- * {@link #getMessagesFromIntent(Intent)}.</p>
- *
- * <p>If a BroadcastReceiver encounters an error while processing
- * this intent it should set the result code appropriately.</p>
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String DATA_SMS_RECEIVED_ACTION =
- "android.intent.action.DATA_SMS_RECEIVED";
-
- /**
- * Broadcast Action: A new WAP PUSH message has been received by the
- * device. The intent will have the following extra
- * values:</p>
- *
- * <ul>
- * <li><em>transactionId (Integer)</em> - The WAP transaction ID</li>
- * <li><em>pduType (Integer)</em> - The WAP PDU type</li>
- * <li><em>header (byte[])</em> - The header of the message</li>
- * <li><em>data (byte[])</em> - The data payload of the message</li>
- * <li><em>contentTypeParameters (HashMap&lt;String,String&gt;)</em>
- * - Any parameters associated with the content type
- * (decoded from the WSP Content-Type header)</li>
- * </ul>
- *
- * <p>If a BroadcastReceiver encounters an error while processing
- * this intent it should set the result code appropriately.</p>
- *
- * <p>The contentTypeParameters extra value is map of content parameters keyed by
- * their names.</p>
- *
- * <p>If any unassigned well-known parameters are encountered, the key of the map will
- * be 'unassigned/0x...', where '...' is the hex value of the unassigned parameter. If
- * a parameter has No-Value the value in the map will be null.</p>
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String WAP_PUSH_RECEIVED_ACTION =
- "android.provider.Telephony.WAP_PUSH_RECEIVED";
-
- /**
- * Broadcast Action: A new Cell Broadcast message has been received
- * by the device. The intent will have the following extra
- * values:</p>
- *
- * <ul>
- * <li><em>message</em> - An SmsCbMessage object containing the broadcast message
- * data. This is not an emergency alert, so ETWS and CMAS data will be null.</li>
- * </ul>
- *
- * <p>The extra values can be extracted using
- * {@link #getMessagesFromIntent(Intent)}.</p>
- *
- * <p>If a BroadcastReceiver encounters an error while processing
- * this intent it should set the result code appropriately.</p>
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String SMS_CB_RECEIVED_ACTION =
- "android.provider.Telephony.SMS_CB_RECEIVED";
-
- /**
- * Broadcast Action: A new Emergency Broadcast message has been received
- * by the device. The intent will have the following extra
- * values:</p>
- *
- * <ul>
- * <li><em>message</em> - An SmsCbMessage object containing the broadcast message
- * data, including ETWS or CMAS warning notification info if present.</li>
- * </ul>
- *
- * <p>The extra values can be extracted using
- * {@link #getMessagesFromIntent(Intent)}.</p>
- *
- * <p>If a BroadcastReceiver encounters an error while processing
- * this intent it should set the result code appropriately.</p>
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String SMS_EMERGENCY_CB_RECEIVED_ACTION =
- "android.provider.Telephony.SMS_EMERGENCY_CB_RECEIVED";
-
- /**
- * Broadcast Action: A new CDMA SMS has been received containing Service Category
- * Program Data (updates the list of enabled broadcast channels). The intent will
- * have the following extra values:</p>
- *
- * <ul>
- * <li><em>operations</em> - An array of CdmaSmsCbProgramData objects containing
- * the service category operations (add/delete/clear) to perform.</li>
- * </ul>
- *
- * <p>The extra values can be extracted using
- * {@link #getMessagesFromIntent(Intent)}.</p>
- *
- * <p>If a BroadcastReceiver encounters an error while processing
- * this intent it should set the result code appropriately.</p>
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION =
- "android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED";
-
- /**
- * Broadcast Action: The SIM storage for SMS messages is full. If
- * space is not freed, messages targeted for the SIM (class 2) may
- * not be saved.
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String SIM_FULL_ACTION =
- "android.provider.Telephony.SIM_FULL";
-
- /**
- * Broadcast Action: An incoming SMS has been rejected by the
- * telephony framework. This intent is sent in lieu of any
- * of the RECEIVED_ACTION intents. The intent will have the
- * following extra value:</p>
- *
- * <ul>
- * <li><em>result</em> - An int result code, eg,
- * <code>{@link #RESULT_SMS_OUT_OF_MEMORY}</code>,
- * indicating the error returned to the network.</li>
- * </ul>
-
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String SMS_REJECTED_ACTION =
- "android.provider.Telephony.SMS_REJECTED";
-
- /**
- * Read the PDUs out of an {@link #SMS_RECEIVED_ACTION} or a
- * {@link #DATA_SMS_RECEIVED_ACTION} intent.
- *
- * @param intent the intent to read from
- * @return an array of SmsMessages for the PDUs
- */
- public static SmsMessage[] getMessagesFromIntent(
- Intent intent) {
- Object[] messages = (Object[]) intent.getSerializableExtra("pdus");
- String format = intent.getStringExtra("format");
- byte[][] pduObjs = new byte[messages.length][];
-
- for (int i = 0; i < messages.length; i++) {
- pduObjs[i] = (byte[]) messages[i];
- }
- byte[][] pdus = new byte[pduObjs.length][];
- int pduCount = pdus.length;
- SmsMessage[] msgs = new SmsMessage[pduCount];
- for (int i = 0; i < pduCount; i++) {
- pdus[i] = pduObjs[i];
- msgs[i] = SmsMessage.createFromPdu(pdus[i], format);
- }
- return msgs;
- }
- }
- }
-
- /**
- * Base columns for tables that contain MMSs.
- */
- public interface BaseMmsColumns extends BaseColumns {
-
- public static final int MESSAGE_BOX_ALL = 0;
- public static final int MESSAGE_BOX_INBOX = 1;
- public static final int MESSAGE_BOX_SENT = 2;
- public static final int MESSAGE_BOX_DRAFTS = 3;
- public static final int MESSAGE_BOX_OUTBOX = 4;
-
- /**
- * The date the message was received.
- * <P>Type: INTEGER (long)</P>
- */
- public static final String DATE = "date";
-
- /**
- * The date the message was sent.
- * <P>Type: INTEGER (long)</P>
- */
- public static final String DATE_SENT = "date_sent";
-
- /**
- * The box which the message belong to, for example, MESSAGE_BOX_INBOX.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_BOX = "msg_box";
-
- /**
- * Has the message been read.
- * <P>Type: INTEGER (boolean)</P>
- */
- public static final String READ = "read";
-
- /**
- * Indicates whether this message has been seen by the user. The "seen" flag will be
- * used to figure out whether we need to throw up a statusbar notification or not.
- */
- public static final String SEEN = "seen";
-
- /**
- * The Message-ID of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MESSAGE_ID = "m_id";
-
- /**
- * The subject of the message, if present.
- * <P>Type: TEXT</P>
- */
- public static final String SUBJECT = "sub";
-
- /**
- * The character set of the subject, if present.
- * <P>Type: INTEGER</P>
- */
- public static final String SUBJECT_CHARSET = "sub_cs";
-
- /**
- * The Content-Type of the message.
- * <P>Type: TEXT</P>
- */
- public static final String CONTENT_TYPE = "ct_t";
-
- /**
- * The Content-Location of the message.
- * <P>Type: TEXT</P>
- */
- public static final String CONTENT_LOCATION = "ct_l";
-
- /**
- * The address of the sender.
- * <P>Type: TEXT</P>
- */
- public static final String FROM = "from";
-
- /**
- * The address of the recipients.
- * <P>Type: TEXT</P>
- */
- public static final String TO = "to";
-
- /**
- * The address of the cc. recipients.
- * <P>Type: TEXT</P>
- */
- public static final String CC = "cc";
-
- /**
- * The address of the bcc. recipients.
- * <P>Type: TEXT</P>
- */
- public static final String BCC = "bcc";
-
- /**
- * The expiry time of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String EXPIRY = "exp";
-
- /**
- * The class of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MESSAGE_CLASS = "m_cls";
-
- /**
- * The type of the message defined by MMS spec.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_TYPE = "m_type";
-
- /**
- * The version of specification that this message conform.
- * <P>Type: INTEGER</P>
- */
- public static final String MMS_VERSION = "v";
-
- /**
- * The size of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_SIZE = "m_size";
-
- /**
- * The priority of the message.
- * <P>Type: TEXT</P>
- */
- public static final String PRIORITY = "pri";
-
- /**
- * The read-report of the message.
- * <P>Type: TEXT</P>
- */
- public static final String READ_REPORT = "rr";
-
- /**
- * Whether the report is allowed.
- * <P>Type: TEXT</P>
- */
- public static final String REPORT_ALLOWED = "rpt_a";
-
- /**
- * The response-status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String RESPONSE_STATUS = "resp_st";
-
- /**
- * The status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String STATUS = "st";
-
- /**
- * The transaction-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String TRANSACTION_ID = "tr_id";
-
- /**
- * The retrieve-status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String RETRIEVE_STATUS = "retr_st";
-
- /**
- * The retrieve-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String RETRIEVE_TEXT = "retr_txt";
-
- /**
- * The character set of the retrieve-text.
- * <P>Type: TEXT</P>
- */
- public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs";
-
- /**
- * The read-status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String READ_STATUS = "read_status";
-
- /**
- * The content-class of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String CONTENT_CLASS = "ct_cls";
-
- /**
- * The delivery-report of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String DELIVERY_REPORT = "d_rpt";
-
- /**
- * The delivery-time-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String DELIVERY_TIME_TOKEN = "d_tm_tok";
-
- /**
- * The delivery-time of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String DELIVERY_TIME = "d_tm";
-
- /**
- * The response-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String RESPONSE_TEXT = "resp_txt";
-
- /**
- * The sender-visibility of the message.
- * <P>Type: TEXT</P>
- */
- public static final String SENDER_VISIBILITY = "s_vis";
-
- /**
- * The reply-charging of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String REPLY_CHARGING = "r_chg";
-
- /**
- * The reply-charging-deadline-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok";
-
- /**
- * The reply-charging-deadline of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl";
-
- /**
- * The reply-charging-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String REPLY_CHARGING_ID = "r_chg_id";
-
- /**
- * The reply-charging-size of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String REPLY_CHARGING_SIZE = "r_chg_sz";
-
- /**
- * The previously-sent-by of the message.
- * <P>Type: TEXT</P>
- */
- public static final String PREVIOUSLY_SENT_BY = "p_s_by";
-
- /**
- * The previously-sent-date of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String PREVIOUSLY_SENT_DATE = "p_s_d";
-
- /**
- * The store of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STORE = "store";
-
- /**
- * The mm-state of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MM_STATE = "mm_st";
-
- /**
- * The mm-flags-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MM_FLAGS_TOKEN = "mm_flg_tok";
-
- /**
- * The mm-flags of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MM_FLAGS = "mm_flg";
-
- /**
- * The store-status of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STORE_STATUS = "store_st";
-
- /**
- * The store-status-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STORE_STATUS_TEXT = "store_st_txt";
-
- /**
- * The stored of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STORED = "stored";
-
- /**
- * The totals of the message.
- * <P>Type: TEXT</P>
- */
- public static final String TOTALS = "totals";
-
- /**
- * The mbox-totals of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MBOX_TOTALS = "mb_t";
-
- /**
- * The mbox-totals-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MBOX_TOTALS_TOKEN = "mb_t_tok";
-
- /**
- * The quotas of the message.
- * <P>Type: TEXT</P>
- */
- public static final String QUOTAS = "qt";
-
- /**
- * The mbox-quotas of the message.
- * <P>Type: TEXT</P>
- */
- public static final String MBOX_QUOTAS = "mb_qt";
-
- /**
- * The mbox-quotas-token of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok";
-
- /**
- * The message-count of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_COUNT = "m_cnt";
-
- /**
- * The start of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String START = "start";
-
- /**
- * The distribution-indicator of the message.
- * <P>Type: TEXT</P>
- */
- public static final String DISTRIBUTION_INDICATOR = "d_ind";
-
- /**
- * The element-descriptor of the message.
- * <P>Type: TEXT</P>
- */
- public static final String ELEMENT_DESCRIPTOR = "e_des";
-
- /**
- * The limit of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String LIMIT = "limit";
-
- /**
- * The recommended-retrieval-mode of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod";
-
- /**
- * The recommended-retrieval-mode-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt";
-
- /**
- * The status-text of the message.
- * <P>Type: TEXT</P>
- */
- public static final String STATUS_TEXT = "st_txt";
-
- /**
- * The applic-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String APPLIC_ID = "apl_id";
-
- /**
- * The reply-applic-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String REPLY_APPLIC_ID = "r_apl_id";
-
- /**
- * The aux-applic-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String AUX_APPLIC_ID = "aux_apl_id";
-
- /**
- * The drm-content of the message.
- * <P>Type: TEXT</P>
- */
- public static final String DRM_CONTENT = "drm_c";
-
- /**
- * The adaptation-allowed of the message.
- * <P>Type: TEXT</P>
- */
- public static final String ADAPTATION_ALLOWED = "adp_a";
-
- /**
- * The replace-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String REPLACE_ID = "repl_id";
-
- /**
- * The cancel-id of the message.
- * <P>Type: TEXT</P>
- */
- public static final String CANCEL_ID = "cl_id";
-
- /**
- * The cancel-status of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String CANCEL_STATUS = "cl_st";
-
- /**
- * The thread ID of the message
- * <P>Type: INTEGER</P>
- */
- public static final String THREAD_ID = "thread_id";
-
- /**
- * Has the message been locked?
- * <P>Type: INTEGER (boolean)</P>
- */
- public static final String LOCKED = "locked";
-
- /**
- * Meta data used externally.
- * <P>Type: TEXT</P>
- */
- public static final String META_DATA = "meta_data";
- }
-
- /**
- * Columns for the "canonical_addresses" table used by MMS and
- * SMS."
- */
- public interface CanonicalAddressesColumns extends BaseColumns {
- /**
- * An address used in MMS or SMS. Email addresses are
- * converted to lower case and are compared by string
- * equality. Other addresses are compared using
- * PHONE_NUMBERS_EQUAL.
- * <P>Type: TEXT</P>
- */
- public static final String ADDRESS = "address";
- }
-
- /**
- * Columns for the "threads" table used by MMS and SMS.
- */
- public interface ThreadsColumns extends BaseColumns {
- /**
- * The date at which the thread was created.
- *
- * <P>Type: INTEGER (long)</P>
- */
- public static final String DATE = "date";
-
- /**
- * A string encoding of the recipient IDs of the recipients of
- * the message, in numerical order and separated by spaces.
- * <P>Type: TEXT</P>
- */
- public static final String RECIPIENT_IDS = "recipient_ids";
-
- /**
- * The message count of the thread.
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_COUNT = "message_count";
- /**
- * Indicates whether all messages of the thread have been read.
- * <P>Type: INTEGER</P>
- */
- public static final String READ = "read";
-
- /**
- * The snippet of the latest message in the thread.
- * <P>Type: TEXT</P>
- */
- public static final String SNIPPET = "snippet";
- /**
- * The charset of the snippet.
- * <P>Type: INTEGER</P>
- */
- public static final String SNIPPET_CHARSET = "snippet_cs";
- /**
- * Type of the thread, either Threads.COMMON_THREAD or
- * Threads.BROADCAST_THREAD.
- * <P>Type: INTEGER</P>
- */
- public static final String TYPE = "type";
- /**
- * Indicates whether there is a transmission error in the thread.
- * <P>Type: INTEGER</P>
- */
- public static final String ERROR = "error";
- /**
- * Indicates whether this thread contains any attachments.
- * <P>Type: INTEGER</P>
- */
- public static final String HAS_ATTACHMENT = "has_attachment";
- }
-
- /**
- * Helper functions for the "threads" table used by MMS and SMS.
- */
- public static final class Threads implements ThreadsColumns {
- private static final String[] ID_PROJECTION = { BaseColumns._ID };
- private static final String STANDARD_ENCODING = "UTF-8";
- private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
- "content://mms-sms/threadID");
- public static final Uri CONTENT_URI = Uri.withAppendedPath(
- MmsSms.CONTENT_URI, "conversations");
- public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
- CONTENT_URI, "obsolete");
-
- public static final int COMMON_THREAD = 0;
- public static final int BROADCAST_THREAD = 1;
-
- // No one should construct an instance of this class.
- private Threads() {
- }
-
- /**
- * This is a single-recipient version of
- * getOrCreateThreadId. It's convenient for use with SMS
- * messages.
- */
- public static long getOrCreateThreadId(Context context, String recipient) {
- Set<String> recipients = new HashSet<String>();
-
- recipients.add(recipient);
- return getOrCreateThreadId(context, recipients);
- }
-
- /**
- * Given the recipients list and subject of an unsaved message,
- * return its thread ID. If the message starts a new thread,
- * allocate a new thread ID. Otherwise, use the appropriate
- * existing thread ID.
- *
- * Find the thread ID of the same set of recipients (in
- * any order, without any additions). If one
- * is found, return it. Otherwise, return a unique thread ID.
- */
- public static long getOrCreateThreadId(
- Context context, Set<String> recipients) {
- Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
-
- for (String recipient : recipients) {
- if (Mms.isEmailAddress(recipient)) {
- recipient = Mms.extractAddrSpec(recipient);
- }
-
- uriBuilder.appendQueryParameter("recipient", recipient);
- }
-
- Uri uri = uriBuilder.build();
- //if (DEBUG) Log.v(TAG, "getOrCreateThreadId uri: " + uri);
-
- Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
- uri, ID_PROJECTION, null, null, null);
- if (cursor != null) {
- try {
- if (cursor.moveToFirst()) {
- return cursor.getLong(0);
- } else {
- Log.e(TAG, "getOrCreateThreadId returned no rows!");
- }
- } finally {
- cursor.close();
- }
- }
-
- Log.e(TAG, "getOrCreateThreadId failed with uri " + uri.toString());
- throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
- }
- }
-
- /**
- * Contains all MMS messages.
- */
- public static final class Mms implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI = Uri.parse("content://mms");
-
- public static final Uri REPORT_REQUEST_URI = Uri.withAppendedPath(
- CONTENT_URI, "report-request");
-
- public static final Uri REPORT_STATUS_URI = Uri.withAppendedPath(
- CONTENT_URI, "report-status");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
-
- /**
- * mailbox = name-addr
- * name-addr = [display-name] angle-addr
- * angle-addr = [CFWS] "<" addr-spec ">" [CFWS]
- */
- public static final Pattern NAME_ADDR_EMAIL_PATTERN =
- Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
-
- /**
- * quoted-string = [CFWS]
- * DQUOTE *([FWS] qcontent) [FWS] DQUOTE
- * [CFWS]
- */
- public static final Pattern QUOTED_STRING_PATTERN =
- Pattern.compile("\\s*\"([^\"]*)\"\\s*");
-
- public static final Cursor query(
- ContentResolver cr, String[] projection) {
- return cr.query(CONTENT_URI, projection, null, null, DEFAULT_SORT_ORDER);
- }
-
- public static final Cursor query(
- ContentResolver cr, String[] projection,
- String where, String orderBy) {
- return cr.query(CONTENT_URI, projection,
- where, null, orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
- }
-
- public static final String getMessageBoxName(int msgBox) {
- switch (msgBox) {
- case MESSAGE_BOX_ALL:
- return "all";
- case MESSAGE_BOX_INBOX:
- return "inbox";
- case MESSAGE_BOX_SENT:
- return "sent";
- case MESSAGE_BOX_DRAFTS:
- return "drafts";
- case MESSAGE_BOX_OUTBOX:
- return "outbox";
- default:
- throw new IllegalArgumentException("Invalid message box: " + msgBox);
- }
- }
-
- public static String extractAddrSpec(String address) {
- Matcher match = NAME_ADDR_EMAIL_PATTERN.matcher(address);
-
- if (match.matches()) {
- return match.group(2);
- }
- return address;
- }
-
- /**
- * Returns true if the address is an email address
- *
- * @param address the input address to be tested
- * @return true if address is an email address
- */
- public static boolean isEmailAddress(String address) {
- if (TextUtils.isEmpty(address)) {
- return false;
- }
-
- String s = extractAddrSpec(address);
- Matcher match = Patterns.EMAIL_ADDRESS.matcher(s);
- return match.matches();
- }
-
- /**
- * Returns true if the number is a Phone number
- *
- * @param number the input number to be tested
- * @return true if number is a Phone number
- */
- public static boolean isPhoneNumber(String number) {
- if (TextUtils.isEmpty(number)) {
- return false;
- }
-
- Matcher match = Patterns.PHONE.matcher(number);
- return match.matches();
- }
-
- /**
- * Contains all MMS messages in the MMS app's inbox.
- */
- public static final class Inbox implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri
- CONTENT_URI = Uri.parse("content://mms/inbox");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
- }
-
- /**
- * Contains all MMS messages in the MMS app's sent box.
- */
- public static final class Sent implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri
- CONTENT_URI = Uri.parse("content://mms/sent");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
- }
-
- /**
- * Contains all MMS messages in the MMS app's drafts box.
- */
- public static final class Draft implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri
- CONTENT_URI = Uri.parse("content://mms/drafts");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
- }
-
- /**
- * Contains all MMS messages in the MMS app's outbox.
- */
- public static final class Outbox implements BaseMmsColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri
- CONTENT_URI = Uri.parse("content://mms/outbox");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "date DESC";
- }
-
- public static final class Addr implements BaseColumns {
- /**
- * The ID of MM which this address entry belongs to.
- */
- public static final String MSG_ID = "msg_id";
-
- /**
- * The ID of contact entry in Phone Book.
- */
- public static final String CONTACT_ID = "contact_id";
-
- /**
- * The address text.
- */
- public static final String ADDRESS = "address";
-
- /**
- * Type of address, must be one of PduHeaders.BCC,
- * PduHeaders.CC, PduHeaders.FROM, PduHeaders.TO.
- */
- public static final String TYPE = "type";
-
- /**
- * Character set of this entry.
- */
- public static final String CHARSET = "charset";
- }
-
- public static final class Part implements BaseColumns {
- /**
- * The identifier of the message which this part belongs to.
- * <P>Type: INTEGER</P>
- */
- public static final String MSG_ID = "mid";
-
- /**
- * The order of the part.
- * <P>Type: INTEGER</P>
- */
- public static final String SEQ = "seq";
-
- /**
- * The content type of the part.
- * <P>Type: TEXT</P>
- */
- public static final String CONTENT_TYPE = "ct";
-
- /**
- * The name of the part.
- * <P>Type: TEXT</P>
- */
- public static final String NAME = "name";
-
- /**
- * The charset of the part.
- * <P>Type: TEXT</P>
- */
- public static final String CHARSET = "chset";
-
- /**
- * The file name of the part.
- * <P>Type: TEXT</P>
- */
- public static final String FILENAME = "fn";
-
- /**
- * The content disposition of the part.
- * <P>Type: TEXT</P>
- */
- public static final String CONTENT_DISPOSITION = "cd";
-
- /**
- * The content ID of the part.
- * <P>Type: INTEGER</P>
- */
- public static final String CONTENT_ID = "cid";
-
- /**
- * The content location of the part.
- * <P>Type: INTEGER</P>
- */
- public static final String CONTENT_LOCATION = "cl";
-
- /**
- * The start of content-type of the message.
- * <P>Type: INTEGER</P>
- */
- public static final String CT_START = "ctt_s";
-
- /**
- * The type of content-type of the message.
- * <P>Type: TEXT</P>
- */
- public static final String CT_TYPE = "ctt_t";
-
- /**
- * The location(on filesystem) of the binary data of the part.
- * <P>Type: INTEGER</P>
- */
- public static final String _DATA = "_data";
-
- public static final String TEXT = "text";
-
- }
-
- public static final class Rate {
- public static final Uri CONTENT_URI = Uri.withAppendedPath(
- Mms.CONTENT_URI, "rate");
- /**
- * When a message was successfully sent.
- * <P>Type: INTEGER</P>
- */
- public static final String SENT_TIME = "sent_time";
- }
-
- public static final class Intents {
- private Intents() {
- // Non-instantiatable.
- }
-
- /**
- * The extra field to store the contents of the Intent,
- * which should be an array of Uri.
- */
- public static final String EXTRA_CONTENTS = "contents";
- /**
- * The extra field to store the type of the contents,
- * which should be an array of String.
- */
- public static final String EXTRA_TYPES = "types";
- /**
- * The extra field to store the 'Cc' addresses.
- */
- public static final String EXTRA_CC = "cc";
- /**
- * The extra field to store the 'Bcc' addresses;
- */
- public static final String EXTRA_BCC = "bcc";
- /**
- * The extra field to store the 'Subject'.
- */
- public static final String EXTRA_SUBJECT = "subject";
- /**
- * Indicates that the contents of specified URIs were changed.
- * The application which is showing or caching these contents
- * should be updated.
- */
- public static final String
- CONTENT_CHANGED_ACTION = "android.intent.action.CONTENT_CHANGED";
- /**
- * An extra field which stores the URI of deleted contents.
- */
- public static final String DELETED_CONTENTS = "deleted_contents";
- }
- }
-
- /**
- * Contains all MMS and SMS messages.
- */
- public static final class MmsSms implements BaseColumns {
- /**
- * The column to distinguish SMS &amp; MMS messages in query results.
- */
- public static final String TYPE_DISCRIMINATOR_COLUMN =
- "transport_type";
-
- public static final Uri CONTENT_URI = Uri.parse("content://mms-sms/");
-
- public static final Uri CONTENT_CONVERSATIONS_URI = Uri.parse(
- "content://mms-sms/conversations");
-
- public static final Uri CONTENT_FILTER_BYPHONE_URI = Uri.parse(
- "content://mms-sms/messages/byphone");
-
- public static final Uri CONTENT_UNDELIVERED_URI = Uri.parse(
- "content://mms-sms/undelivered");
-
- public static final Uri CONTENT_DRAFT_URI = Uri.parse(
- "content://mms-sms/draft");
-
- public static final Uri CONTENT_LOCKED_URI = Uri.parse(
- "content://mms-sms/locked");
-
- /***
- * Pass in a query parameter called "pattern" which is the text
- * to search for.
- * The sort order is fixed to be thread_id ASC,date DESC.
- */
- public static final Uri SEARCH_URI = Uri.parse(
- "content://mms-sms/search");
-
- // Constants for message protocol types.
- public static final int SMS_PROTO = 0;
- public static final int MMS_PROTO = 1;
-
- // Constants for error types of pending messages.
- public static final int NO_ERROR = 0;
- public static final int ERR_TYPE_GENERIC = 1;
- public static final int ERR_TYPE_SMS_PROTO_TRANSIENT = 2;
- public static final int ERR_TYPE_MMS_PROTO_TRANSIENT = 3;
- public static final int ERR_TYPE_TRANSPORT_FAILURE = 4;
- public static final int ERR_TYPE_GENERIC_PERMANENT = 10;
- public static final int ERR_TYPE_SMS_PROTO_PERMANENT = 11;
- public static final int ERR_TYPE_MMS_PROTO_PERMANENT = 12;
-
- public static final class PendingMessages implements BaseColumns {
- public static final Uri CONTENT_URI = Uri.withAppendedPath(
- MmsSms.CONTENT_URI, "pending");
- /**
- * The type of transport protocol(MMS or SMS).
- * <P>Type: INTEGER</P>
- */
- public static final String PROTO_TYPE = "proto_type";
- /**
- * The ID of the message to be sent or downloaded.
- * <P>Type: INTEGER</P>
- */
- public static final String MSG_ID = "msg_id";
- /**
- * The type of the message to be sent or downloaded.
- * This field is only valid for MM. For SM, its value is always
- * set to 0.
- */
- public static final String MSG_TYPE = "msg_type";
- /**
- * The type of the error code.
- * <P>Type: INTEGER</P>
- */
- public static final String ERROR_TYPE = "err_type";
- /**
- * The error code of sending/retrieving process.
- * <P>Type: INTEGER</P>
- */
- public static final String ERROR_CODE = "err_code";
- /**
- * How many times we tried to send or download the message.
- * <P>Type: INTEGER</P>
- */
- public static final String RETRY_INDEX = "retry_index";
- /**
- * The time to do next retry.
- */
- public static final String DUE_TIME = "due_time";
- /**
- * The time we last tried to send or download the message.
- */
- public static final String LAST_TRY = "last_try";
- }
-
- public static final class WordsTable {
- public static final String ID = "_id";
- public static final String SOURCE_ROW_ID = "source_id";
- public static final String TABLE_ID = "table_to_use";
- public static final String INDEXED_TEXT = "index_text";
- }
- }
-
- public static final class Carriers implements BaseColumns {
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://telephony/carriers");
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = "name ASC";
-
- public static final String NAME = "name";
-
- public static final String APN = "apn";
-
- public static final String PROXY = "proxy";
-
- public static final String PORT = "port";
-
- public static final String MMSPROXY = "mmsproxy";
-
- public static final String MMSPORT = "mmsport";
-
- public static final String SERVER = "server";
-
- public static final String USER = "user";
-
- public static final String PASSWORD = "password";
-
- public static final String MMSC = "mmsc";
-
- public static final String MCC = "mcc";
-
- public static final String MNC = "mnc";
-
- public static final String NUMERIC = "numeric";
-
- public static final String AUTH_TYPE = "authtype";
-
- public static final String TYPE = "type";
-
- public static final String INACTIVE_TIMER = "inactivetimer";
-
- // Only if enabled try Data Connection.
- public static final String ENABLED = "enabled";
-
- // Rules apply based on class.
- public static final String CLASS = "class";
-
- /**
- * The protocol to be used to connect to this APN.
- *
- * One of the PDP_type values in TS 27.007 section 10.1.1.
- * For example, "IP", "IPV6", "IPV4V6", or "PPP".
- */
- public static final String PROTOCOL = "protocol";
-
- /**
- * The protocol to be used to connect to this APN when roaming.
- *
- * The syntax is the same as protocol.
- */
- public static final String ROAMING_PROTOCOL = "roaming_protocol";
-
- public static final String CURRENT = "current";
-
- /**
- * Current status of APN
- * true : enabled APN, false : disabled APN.
- */
- public static final String CARRIER_ENABLED = "carrier_enabled";
-
- /**
- * Radio Access Technology info
- * To check what values can hold, refer to ServiceState.java.
- * This should be spread to other technologies,
- * but currently only used for LTE(14) and EHRPD(13).
- */
- public static final String BEARER = "bearer";
- }
-
- /**
- * Contains received SMS cell broadcast messages.
- */
- public static final class CellBroadcasts implements BaseColumns {
-
- /** Not instantiable. */
- private CellBroadcasts() {}
-
- /**
- * The content:// style URL for this table
- */
- public static final Uri CONTENT_URI =
- Uri.parse("content://cellbroadcasts");
-
- /**
- * Message geographical scope.
- * <P>Type: INTEGER</P>
- */
- public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
-
- /**
- * Message serial number.
- * <P>Type: INTEGER</P>
- */
- public static final String SERIAL_NUMBER = "serial_number";
-
- /**
- * PLMN of broadcast sender. (SERIAL_NUMBER + PLMN + LAC + CID) uniquely identifies a
- * broadcast for duplicate detection purposes.
- * <P>Type: TEXT</P>
- */
- public static final String PLMN = "plmn";
-
- /**
- * Location Area (GSM) or Service Area (UMTS) of broadcast sender. Unused for CDMA.
- * Only included if Geographical Scope of message is not PLMN wide (01).
- * <P>Type: INTEGER</P>
- */
- public static final String LAC = "lac";
-
- /**
- * Cell ID of message sender (GSM/UMTS). Unused for CDMA. Only included when the
- * Geographical Scope of message is cell wide (00 or 11).
- * <P>Type: INTEGER</P>
- */
- public static final String CID = "cid";
-
- /**
- * Message code (OBSOLETE: merged into SERIAL_NUMBER).
- * <P>Type: INTEGER</P>
- */
- public static final String V1_MESSAGE_CODE = "message_code";
-
- /**
- * Message identifier (OBSOLETE: renamed to SERVICE_CATEGORY).
- * <P>Type: INTEGER</P>
- */
- public static final String V1_MESSAGE_IDENTIFIER = "message_id";
-
- /**
- * Service category (GSM/UMTS message identifier, CDMA service category).
- * <P>Type: INTEGER</P>
- */
- public static final String SERVICE_CATEGORY = "service_category";
-
- /**
- * Message language code.
- * <P>Type: TEXT</P>
- */
- public static final String LANGUAGE_CODE = "language";
-
- /**
- * Message body.
- * <P>Type: TEXT</P>
- */
- public static final String MESSAGE_BODY = "body";
-
- /**
- * Message delivery time.
- * <P>Type: INTEGER (long)</P>
- */
- public static final String DELIVERY_TIME = "date";
-
- /**
- * Has the message been viewed?
- * <P>Type: INTEGER (boolean)</P>
- */
- public static final String MESSAGE_READ = "read";
-
- /**
- * Message format (3GPP or 3GPP2).
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_FORMAT = "format";
-
- /**
- * Message priority (including emergency).
- * <P>Type: INTEGER</P>
- */
- public static final String MESSAGE_PRIORITY = "priority";
-
- /**
- * ETWS warning type (ETWS alerts only).
- * <P>Type: INTEGER</P>
- */
- public static final String ETWS_WARNING_TYPE = "etws_warning_type";
-
- /**
- * CMAS message class (CMAS alerts only).
- * <P>Type: INTEGER</P>
- */
- public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
-
- /**
- * CMAS category (CMAS alerts only).
- * <P>Type: INTEGER</P>
- */
- public static final String CMAS_CATEGORY = "cmas_category";
-
- /**
- * CMAS response type (CMAS alerts only).
- * <P>Type: INTEGER</P>
- */
- public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
-
- /**
- * CMAS severity (CMAS alerts only).
- * <P>Type: INTEGER</P>
- */
- public static final String CMAS_SEVERITY = "cmas_severity";
-
- /**
- * CMAS urgency (CMAS alerts only).
- * <P>Type: INTEGER</P>
- */
- public static final String CMAS_URGENCY = "cmas_urgency";
-
- /**
- * CMAS certainty (CMAS alerts only).
- * <P>Type: INTEGER</P>
- */
- public static final String CMAS_CERTAINTY = "cmas_certainty";
-
- /**
- * The default sort order for this table
- */
- public static final String DEFAULT_SORT_ORDER = DELIVERY_TIME + " DESC";
-
- /**
- * Query columns for instantiating {@link android.telephony.CellBroadcastMessage} objects.
- */
- public static final String[] QUERY_COLUMNS = {
- _ID,
- GEOGRAPHICAL_SCOPE,
- PLMN,
- LAC,
- CID,
- SERIAL_NUMBER,
- SERVICE_CATEGORY,
- LANGUAGE_CODE,
- MESSAGE_BODY,
- DELIVERY_TIME,
- MESSAGE_READ,
- MESSAGE_FORMAT,
- MESSAGE_PRIORITY,
- ETWS_WARNING_TYPE,
- CMAS_MESSAGE_CLASS,
- CMAS_CATEGORY,
- CMAS_RESPONSE_TYPE,
- CMAS_SEVERITY,
- CMAS_URGENCY,
- CMAS_CERTAINTY
- };
- }
-
- public static final class Intents {
- private Intents() {
- // Not instantiable
- }
-
- /**
- * Broadcast Action: A "secret code" has been entered in the dialer. Secret codes are
- * of the form *#*#<code>#*#*. The intent will have the data URI:</p>
- *
- * <p><code>android_secret_code://&lt;code&gt;</code></p>
- */
- public static final String SECRET_CODE_ACTION =
- "android.provider.Telephony.SECRET_CODE";
-
- /**
- * Broadcast Action: The Service Provider string(s) have been updated. Activities or
- * services that use these strings should update their display.
- * The intent will have the following extra values:</p>
- * <ul>
- * <li><em>showPlmn</em> - Boolean that indicates whether the PLMN should be shown.</li>
- * <li><em>plmn</em> - The operator name of the registered network, as a string.</li>
- * <li><em>showSpn</em> - Boolean that indicates whether the SPN should be shown.</li>
- * <li><em>spn</em> - The service provider name, as a string.</li>
- * </ul>
- * Note that <em>showPlmn</em> may indicate that <em>plmn</em> should be displayed, even
- * though the value for <em>plmn</em> is null. This can happen, for example, if the phone
- * has not registered to a network yet. In this case the receiver may substitute an
- * appropriate placeholder string (eg, "No service").
- *
- * It is recommended to display <em>plmn</em> before / above <em>spn</em> if
- * both are displayed.
- *
- * <p>Note this is a protected intent that can only be sent
- * by the system.
- */
- public static final String SPN_STRINGS_UPDATED_ACTION =
- "android.provider.Telephony.SPN_STRINGS_UPDATED";
-
- public static final String EXTRA_SHOW_PLMN = "showPlmn";
- public static final String EXTRA_PLMN = "plmn";
- public static final String EXTRA_SHOW_SPN = "showSpn";
- public static final String EXTRA_SPN = "spn";
- }
-}
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 97c0209..6296b11 100755
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -2448,7 +2448,7 @@ public class BluetoothService extends IBluetooth.Stub {
BluetoothDeviceProfileState state = mDeviceProfileState.get(address);
if (state == null) return;
- state.quit();
+ state.doQuit();
mDeviceProfileState.remove(address);
}
diff --git a/core/java/android/text/format/DateUtils.java b/core/java/android/text/format/DateUtils.java
index da10311..2e962a0 100644
--- a/core/java/android/text/format/DateUtils.java
+++ b/core/java/android/text/format/DateUtils.java
@@ -161,12 +161,17 @@ public class DateUtils
public static final int FORMAT_NO_YEAR = 0x00008;
public static final int FORMAT_SHOW_DATE = 0x00010;
public static final int FORMAT_NO_MONTH_DAY = 0x00020;
+ @Deprecated
public static final int FORMAT_12HOUR = 0x00040;
+ @Deprecated
public static final int FORMAT_24HOUR = 0x00080;
+ @Deprecated
public static final int FORMAT_CAP_AMPM = 0x00100;
public static final int FORMAT_NO_NOON = 0x00200;
+ @Deprecated
public static final int FORMAT_CAP_NOON = 0x00400;
public static final int FORMAT_NO_MIDNIGHT = 0x00800;
+ @Deprecated
public static final int FORMAT_CAP_MIDNIGHT = 0x01000;
/**
* @deprecated Use
@@ -181,19 +186,25 @@ public class DateUtils
public static final int FORMAT_NUMERIC_DATE = 0x20000;
public static final int FORMAT_ABBREV_RELATIVE = 0x40000;
public static final int FORMAT_ABBREV_ALL = 0x80000;
+ @Deprecated
public static final int FORMAT_CAP_NOON_MIDNIGHT = (FORMAT_CAP_NOON | FORMAT_CAP_MIDNIGHT);
+ @Deprecated
public static final int FORMAT_NO_NOON_MIDNIGHT = (FORMAT_NO_NOON | FORMAT_NO_MIDNIGHT);
// Date and time format strings that are constant and don't need to be
// translated.
/**
* This is not actually the preferred 24-hour date format in all locales.
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static final String HOUR_MINUTE_24 = "%H:%M";
public static final String MONTH_FORMAT = "%B";
/**
* This is not actually a useful month name in all locales.
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static final String ABBREV_MONTH_FORMAT = "%b";
public static final String NUMERIC_MONTH_FORMAT = "%m";
public static final String MONTH_DAY_FORMAT = "%-d";
@@ -207,6 +218,7 @@ public class DateUtils
// The index is constructed from a bit-wise OR of the boolean values:
// {showTime, showYear, showWeekDay}. For example, if showYear and
// showWeekDay are both true, then the index would be 3.
+ /** @deprecated do not use. */
public static final int sameYearTable[] = {
com.android.internal.R.string.same_year_md1_md2,
com.android.internal.R.string.same_year_wday1_md1_wday2_md2,
@@ -233,6 +245,7 @@ public class DateUtils
// The index is constructed from a bit-wise OR of the boolean values:
// {showTime, showYear, showWeekDay}. For example, if showYear and
// showWeekDay are both true, then the index would be 3.
+ /** @deprecated do not use. */
public static final int sameMonthTable[] = {
com.android.internal.R.string.same_month_md1_md2,
com.android.internal.R.string.same_month_wday1_md1_wday2_md2,
@@ -259,7 +272,9 @@ public class DateUtils
*
* @more <p>
* e.g. "Sunday" or "January"
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static final int LENGTH_LONG = 10;
/**
@@ -268,7 +283,9 @@ public class DateUtils
*
* @more <p>
* e.g. "Sun" or "Jan"
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static final int LENGTH_MEDIUM = 20;
/**
@@ -278,14 +295,18 @@ public class DateUtils
* <p>e.g. "Su" or "Jan"
* <p>In most languages, the results returned for LENGTH_SHORT will be the same as
* the results returned for {@link #LENGTH_MEDIUM}.
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static final int LENGTH_SHORT = 30;
/**
* Request an even shorter abbreviated version of the name.
* Do not use this. Currently this will always return the same result
* as {@link #LENGTH_SHORT}.
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static final int LENGTH_SHORTER = 40;
/**
@@ -295,7 +316,9 @@ public class DateUtils
* <p>e.g. "S", "T", "T" or "J"
* <p>In some languages, the results returned for LENGTH_SHORTEST will be the same as
* the results returned for {@link #LENGTH_SHORT}.
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static final int LENGTH_SHORTEST = 50;
/**
@@ -309,7 +332,9 @@ public class DateUtils
* Undefined lengths will return {@link #LENGTH_MEDIUM}
* but may return something different in the future.
* @throws IndexOutOfBoundsException if the dayOfWeek is out of bounds.
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static String getDayOfWeekString(int dayOfWeek, int abbrev) {
int[] list;
switch (abbrev) {
@@ -330,7 +355,9 @@ public class DateUtils
* @param ampm Either {@link Calendar#AM Calendar.AM} or {@link Calendar#PM Calendar.PM}.
* @throws IndexOutOfBoundsException if the ampm is out of bounds.
* @return Localized version of "AM" or "PM".
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static String getAMPMString(int ampm) {
Resources r = Resources.getSystem();
return r.getString(sAmPm[ampm - Calendar.AM]);
@@ -345,7 +372,9 @@ public class DateUtils
* Undefined lengths will return {@link #LENGTH_MEDIUM}
* but may return something different in the future.
* @return Localized month of the year.
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static String getMonthString(int month, int abbrev) {
// Note that here we use sMonthsMedium for MEDIUM, SHORT and SHORTER.
// This is a shortcut to not spam the translators with too many variations
@@ -378,7 +407,9 @@ public class DateUtils
* but may return something different in the future.
* @return Localized month of the year.
* @hide Pending API council approval
+ * @deprecated use {@link java.text.SimpleDateFormat} instead.
*/
+ @Deprecated
public static String getStandaloneMonthString(int month, int abbrev) {
// Note that here we use sMonthsMedium for MEDIUM, SHORT and SHORTER.
// This is a shortcut to not spam the translators with too many variations
@@ -1618,7 +1649,7 @@ public class DateUtils
String result;
long now = System.currentTimeMillis();
- long span = now - millis;
+ long span = Math.abs(now - millis);
synchronized (DateUtils.class) {
if (sNowTime == null) {
diff --git a/core/java/android/view/FocusFinder.java b/core/java/android/view/FocusFinder.java
index 9063cea..31a9f05 100644
--- a/core/java/android/view/FocusFinder.java
+++ b/core/java/android/view/FocusFinder.java
@@ -250,8 +250,8 @@ public class FocusFinder {
// only interested in other non-root views
if (focusable == focused || focusable == root) continue;
- // get visible bounds of other view in same coordinate system
- focusable.getDrawingRect(mOtherRect);
+ // get focus bounds of other view in same coordinate system
+ focusable.getFocusRect(mOtherRect);
root.offsetDescendantRectToMyCoords(focusable, mOtherRect);
if (isBetterCandidate(direction, focusedRect, mOtherRect, mBestCandidateRect)) {
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index fd302dc..ed4c75c 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -531,7 +531,7 @@ public class SurfaceView extends View {
mSurface.transferFrom(mNewSurface);
- if (visible) {
+ if (visible && mSurface.isValid()) {
if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) {
mSurfaceCreated = true;
mIsCreating = true;
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index f0ca302..f2a80d0 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -8737,6 +8737,18 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
}
/**
+ * When searching for a view to focus this rectangle is used when considering if this view is
+ * a good candidate for receiving focus.
+ *
+ * By default, the rectangle is the {@link #getDrawingRect}) of the view.
+ *
+ * @param r The rectangle to fill in, in this view's coordinates.
+ */
+ public void getFocusRect(Rect r) {
+ getDrawingRect(r);
+ }
+
+ /**
* Utility method to retrieve the inverse of the current mMatrix property.
* We cache the matrix to avoid recalculating it when transform properties
* have not changed.
diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java
index 501db7d..bcab1b1 100644
--- a/core/java/android/webkit/WebViewClassic.java
+++ b/core/java/android/webkit/WebViewClassic.java
@@ -686,6 +686,10 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
// It's used to dismiss the dialog in destroy if not done before.
private AlertDialog mListBoxDialog = null;
+ // Reference to the save password dialog so it can be dimissed in
+ // destroy if not done before.
+ private AlertDialog mSavePasswordDialog = null;
+
static final String LOGTAG = "webview";
private ZoomManager mZoomManager;
@@ -1826,7 +1830,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
neverRemember.getData().putString("password", password);
neverRemember.obj = resumeMsg;
- new AlertDialog.Builder(mContext)
+ mSavePasswordDialog = new AlertDialog.Builder(mContext)
.setTitle(com.android.internal.R.string.save_password_label)
.setMessage(com.android.internal.R.string.save_password_message)
.setPositiveButton(com.android.internal.R.string.save_password_notnow,
@@ -1837,6 +1841,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
resumeMsg.sendToTarget();
mResumeMsg = null;
}
+ mSavePasswordDialog = null;
}
})
.setNeutralButton(com.android.internal.R.string.save_password_remember,
@@ -1847,6 +1852,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
remember.sendToTarget();
mResumeMsg = null;
}
+ mSavePasswordDialog = null;
}
})
.setNegativeButton(com.android.internal.R.string.save_password_never,
@@ -1857,6 +1863,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
neverRemember.sendToTarget();
mResumeMsg = null;
}
+ mSavePasswordDialog = null;
}
})
.setOnCancelListener(new OnCancelListener() {
@@ -1866,6 +1873,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
resumeMsg.sendToTarget();
mResumeMsg = null;
}
+ mSavePasswordDialog = null;
}
}).show();
// Return true so that WebViewCore will pause while the dialog is
@@ -2105,6 +2113,10 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
mListBoxDialog.dismiss();
mListBoxDialog = null;
}
+ if (mSavePasswordDialog != null) {
+ mSavePasswordDialog.dismiss();
+ mSavePasswordDialog = null;
+ }
if (mWebViewCore != null) {
// Tell WebViewCore to destroy itself
synchronized (this) {
diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java
index 323fcf0..b72b8cb 100644
--- a/core/java/android/widget/Gallery.java
+++ b/core/java/android/widget/Gallery.java
@@ -1192,15 +1192,15 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList
case KeyEvent.KEYCODE_DPAD_LEFT:
if (movePrevious()) {
playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT);
+ return true;
}
- return true;
-
+ break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (moveNext()) {
playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT);
+ return true;
}
- return true;
-
+ break;
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
mReceivedInvokeKeyDown = true;
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java
index ff8c0a1..37e0b90 100644
--- a/core/java/android/widget/GridView.java
+++ b/core/java/android/widget/GridView.java
@@ -2207,8 +2207,13 @@ public class GridView extends AbsListView {
int height = view.getHeight();
if (height > 0) {
final int numColumns = mNumColumns;
- final int whichRow = mFirstPosition / numColumns;
final int rowCount = (mItemCount + numColumns - 1) / numColumns;
+ // In case of stackFromBottom the calculation of whichRow needs
+ // to take into account that counting from the top the first row
+ // might not be entirely filled.
+ final int oddItemsOnFirstRow = isStackFromBottom() ? ((rowCount * numColumns) -
+ mItemCount) : 0;
+ final int whichRow = (mFirstPosition + oddItemsOnFirstRow) / numColumns;
return Math.max(whichRow * 100 - (top * 100) / height +
(int) ((float) mScrollY / getHeight() * rowCount * 100), 0);
}
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java
index 18c4fe6..ff0579c 100644
--- a/core/java/android/widget/HorizontalScrollView.java
+++ b/core/java/android/widget/HorizontalScrollView.java
@@ -22,6 +22,7 @@ import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.FocusFinder;
import android.view.InputDevice;
import android.view.KeyEvent;
@@ -62,6 +63,7 @@ public class HorizontalScrollView extends FrameLayout {
private static final float MAX_SCROLL_FACTOR = ScrollView.MAX_SCROLL_FACTOR;
+ private static final String TAG = "HorizontalScrollView";
private long mLastScroll;
@@ -456,6 +458,12 @@ public class HorizontalScrollView extends FrameLayout {
}
final int pointerIndex = ev.findPointerIndex(activePointerId);
+ if (pointerIndex == -1) {
+ Log.e(TAG, "Invalid pointerId=" + activePointerId
+ + " in onInterceptTouchEvent");
+ break;
+ }
+
final int x = (int) ev.getX(pointerIndex);
final int xDiff = (int) Math.abs(x - mLastMotionX);
if (xDiff > mTouchSlop) {
@@ -557,6 +565,11 @@ public class HorizontalScrollView extends FrameLayout {
}
case MotionEvent.ACTION_MOVE:
final int activePointerIndex = ev.findPointerIndex(mActivePointerId);
+ if (activePointerIndex == -1) {
+ Log.e(TAG, "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
+ break;
+ }
+
final int x = (int) ev.getX(activePointerIndex);
int deltaX = mLastMotionX - x;
if (!mIsBeingDragged && Math.abs(deltaX) > mTouchSlop) {
diff --git a/core/java/android/widget/MediaController.java b/core/java/android/widget/MediaController.java
index fc35f05..f76ab2b 100644
--- a/core/java/android/widget/MediaController.java
+++ b/core/java/android/widget/MediaController.java
@@ -477,7 +477,8 @@ public class MediaController extends FrameLayout {
return true;
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|| keyCode == KeyEvent.KEYCODE_VOLUME_UP
- || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
+ || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE
+ || keyCode == KeyEvent.KEYCODE_CAMERA) {
// don't show the controls for volume adjustment
return super.dispatchKeyEvent(event);
} else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index ebc54f4..8747dc3 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -25,6 +25,7 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.FocusFinder;
import android.view.InputDevice;
import android.view.KeyEvent;
@@ -69,6 +70,8 @@ public class ScrollView extends FrameLayout {
static final float MAX_SCROLL_FACTOR = 0.5f;
+ private static final String TAG = "ScrollView";
+
private long mLastScroll;
private final Rect mTempRect = new Rect();
@@ -478,6 +481,12 @@ public class ScrollView extends FrameLayout {
}
final int pointerIndex = ev.findPointerIndex(activePointerId);
+ if (pointerIndex == -1) {
+ Log.e(TAG, "Invalid pointerId=" + activePointerId
+ + " in onInterceptTouchEvent");
+ break;
+ }
+
final int y = (int) ev.getY(pointerIndex);
final int yDiff = Math.abs(y - mLastMotionY);
if (yDiff > mTouchSlop) {
@@ -585,6 +594,11 @@ public class ScrollView extends FrameLayout {
}
case MotionEvent.ACTION_MOVE:
final int activePointerIndex = ev.findPointerIndex(mActivePointerId);
+ if (activePointerIndex == -1) {
+ Log.e(TAG, "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
+ break;
+ }
+
final int y = (int) ev.getY(activePointerIndex);
int deltaY = mLastMotionY - y;
if (!mIsBeingDragged && Math.abs(deltaY) > mTouchSlop) {
diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java
index a0e961f..86433d4 100644
--- a/core/java/android/widget/SearchView.java
+++ b/core/java/android/widget/SearchView.java
@@ -1506,6 +1506,9 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
// because the voice search activity will always need to insert "QUERY" into
// it anyway.
Bundle queryExtras = new Bundle();
+ if (mAppSearchData != null) {
+ queryExtras.putParcelable(SearchManager.APP_DATA, mAppSearchData);
+ }
// Now build the intent to launch the voice search. Add all necessary
// extras to launch the voice recognizer, and then all the necessary extras
@@ -1595,8 +1598,8 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
} catch (RuntimeException e2 ) {
rowNum = -1;
}
- Log.w(LOG_TAG, "Search Suggestions cursor at row " + rowNum +
- " returned exception" + e.toString());
+ Log.w(LOG_TAG, "Search suggestions cursor at row " + rowNum +
+ " returned exception.", e);
return null;
}
}
diff --git a/core/java/android/widget/SimpleExpandableListAdapter.java b/core/java/android/widget/SimpleExpandableListAdapter.java
index 015c169..f514374 100644
--- a/core/java/android/widget/SimpleExpandableListAdapter.java
+++ b/core/java/android/widget/SimpleExpandableListAdapter.java
@@ -38,6 +38,8 @@ import java.util.Map;
*/
public class SimpleExpandableListAdapter extends BaseExpandableListAdapter {
private List<? extends Map<String, ?>> mGroupData;
+ // Keeps track of if a group is currently expanded or not
+ private boolean[] mIsGroupExpanded;
private int mExpandedGroupLayout;
private int mCollapsedGroupLayout;
private String[] mGroupFrom;
@@ -196,6 +198,8 @@ public class SimpleExpandableListAdapter extends BaseExpandableListAdapter {
int childLayout, int lastChildLayout, String[] childFrom,
int[] childTo) {
mGroupData = groupData;
+ // Initially all groups are not expanded
+ mIsGroupExpanded = new boolean[groupData.size()];
mExpandedGroupLayout = expandedGroupLayout;
mCollapsedGroupLayout = collapsedGroupLayout;
mGroupFrom = groupFrom;
@@ -298,4 +302,52 @@ public class SimpleExpandableListAdapter extends BaseExpandableListAdapter {
return true;
}
+ /**
+ * {@inheritDoc}
+ * @return 1 for the last child in a group, 0 for the other children.
+ */
+ @Override
+ public int getChildType(int groupPosition, int childPosition) {
+ final int childrenInGroup = getChildrenCount(groupPosition);
+ return childPosition == childrenInGroup - 1 ? 1 : 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @return 2, one type for the last child in a group, one for the other children.
+ */
+ @Override
+ public int getChildTypeCount() {
+ return 2;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @return 1 for an expanded group view, 0 for a collapsed one.
+ */
+ @Override
+ public int getGroupType(int groupPosition) {
+ return mIsGroupExpanded[groupPosition] ? 1 : 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @return 2, one for a collapsed group view, one for an expanded one.
+ */
+ @Override
+ public int getGroupTypeCount() {
+ return 2;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void onGroupCollapsed(int groupPosition) {
+ mIsGroupExpanded[groupPosition] = false;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void onGroupExpanded(int groupPosition) {
+ mIsGroupExpanded[groupPosition] = true;
+ }
}
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java
index 56f6651..cea613f 100644
--- a/core/java/android/widget/Switch.java
+++ b/core/java/android/widget/Switch.java
@@ -686,7 +686,7 @@ public class Switch extends CompoundButton {
@Override
public void setChecked(boolean checked) {
super.setChecked(checked);
- mThumbPosition = checked ? getThumbScrollRange() : 0;
+ mThumbPosition = isChecked() ? getThumbScrollRange() : 0;
invalidate();
}
diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java
index 8bb9348..238dc55 100644
--- a/core/java/android/widget/TabHost.java
+++ b/core/java/android/widget/TabHost.java
@@ -48,6 +48,10 @@ import java.util.List;
*/
public class TabHost extends FrameLayout implements ViewTreeObserver.OnTouchModeChangeListener {
+ private static final int TABWIDGET_LOCATION_LEFT = 0;
+ private static final int TABWIDGET_LOCATION_TOP = 1;
+ private static final int TABWIDGET_LOCATION_RIGHT = 2;
+ private static final int TABWIDGET_LOCATION_BOTTOM = 3;
private TabWidget mTabWidget;
private FrameLayout mTabContent;
private List<TabSpec> mTabSpecs = new ArrayList<TabSpec>(2);
@@ -293,22 +297,73 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
return mTabContent;
}
+ /**
+ * Get the location of the TabWidget.
+ *
+ * @return The TabWidget location.
+ */
+ private int getTabWidgetLocation() {
+ int location = TABWIDGET_LOCATION_TOP;
+
+ switch (mTabWidget.getOrientation()) {
+ case LinearLayout.VERTICAL:
+ location = (mTabContent.getLeft() < mTabWidget.getLeft()) ? TABWIDGET_LOCATION_RIGHT
+ : TABWIDGET_LOCATION_LEFT;
+ break;
+ case LinearLayout.HORIZONTAL:
+ default:
+ location = (mTabContent.getTop() < mTabWidget.getTop()) ? TABWIDGET_LOCATION_BOTTOM
+ : TABWIDGET_LOCATION_TOP;
+ break;
+ }
+ return location;
+ }
+
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
final boolean handled = super.dispatchKeyEvent(event);
- // unhandled key ups change focus to tab indicator for embedded activities
- // when there is nothing that will take focus from default focus searching
+ // unhandled key events change focus to tab indicator for embedded
+ // activities when there is nothing that will take focus from default
+ // focus searching
if (!handled
&& (event.getAction() == KeyEvent.ACTION_DOWN)
- && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP)
&& (mCurrentView != null)
&& (mCurrentView.isRootNamespace())
- && (mCurrentView.hasFocus())
- && (mCurrentView.findFocus().focusSearch(View.FOCUS_UP) == null)) {
- mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus();
- playSoundEffect(SoundEffectConstants.NAVIGATION_UP);
- return true;
+ && (mCurrentView.hasFocus())) {
+ int keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_UP;
+ int directionShouldChangeFocus = View.FOCUS_UP;
+ int soundEffect = SoundEffectConstants.NAVIGATION_UP;
+
+ switch (getTabWidgetLocation()) {
+ case TABWIDGET_LOCATION_LEFT:
+ keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_LEFT;
+ directionShouldChangeFocus = View.FOCUS_LEFT;
+ soundEffect = SoundEffectConstants.NAVIGATION_LEFT;
+ break;
+ case TABWIDGET_LOCATION_RIGHT:
+ keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_RIGHT;
+ directionShouldChangeFocus = View.FOCUS_RIGHT;
+ soundEffect = SoundEffectConstants.NAVIGATION_RIGHT;
+ break;
+ case TABWIDGET_LOCATION_BOTTOM:
+ keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_DOWN;
+ directionShouldChangeFocus = View.FOCUS_DOWN;
+ soundEffect = SoundEffectConstants.NAVIGATION_DOWN;
+ break;
+ case TABWIDGET_LOCATION_TOP:
+ default:
+ keyCodeShouldChangeFocus = KeyEvent.KEYCODE_DPAD_UP;
+ directionShouldChangeFocus = View.FOCUS_UP;
+ soundEffect = SoundEffectConstants.NAVIGATION_UP;
+ break;
+ }
+ if (event.getKeyCode() == keyCodeShouldChangeFocus
+ && mCurrentView.findFocus().focusSearch(directionShouldChangeFocus) == null) {
+ mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus();
+ playSoundEffect(soundEffect);
+ return true;
+ }
}
return handled;
}