summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/SyncManager.java1
-rw-r--r--core/java/android/content/pm/PackageParser.java6
-rw-r--r--core/java/android/net/NetworkUtils.java13
-rw-r--r--core/java/android/os/storage/IMountService.java32
-rw-r--r--core/java/android/text/format/Formatter.java35
-rw-r--r--core/java/android/webkit/BrowserFrame.java3
-rw-r--r--core/java/android/webkit/FrameLoader.java3
-rw-r--r--core/java/android/webkit/WebSettings.java21
8 files changed, 80 insertions, 34 deletions
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 2fa2834..f45cf2a 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -1373,6 +1373,7 @@ public class SyncManager implements OnAccountsUpdateListener {
public void handleMessage(Message msg) {
long earliestFuturePollTime = Long.MAX_VALUE;
long nextPendingSyncTime = Long.MAX_VALUE;
+
// Setting the value here instead of a method because we want the dumpsys logs
// to have the most recent value used.
try {
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index c8ca080..ad74707 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -3086,11 +3086,7 @@ public class PackageParser {
if (!sCompatibilityModeEnabled) {
ai.disableCompatibilityMode();
}
- if (p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
- ai.enabled = true;
- } else if (p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
- ai.enabled = false;
- }
+ ai.enabled = p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
return ai;
}
diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java
index 8a653dd..f1bf852 100644
--- a/core/java/android/net/NetworkUtils.java
+++ b/core/java/android/net/NetworkUtils.java
@@ -125,24 +125,19 @@ public class NetworkUtils {
/**
* Convert a IPv4 address from an integer to an InetAddress.
- * @param hostAddr is an Int corresponding to the IPv4 address in network byte order
- * @return the IP address as an {@code InetAddress}, returns null if
- * unable to convert or if the int is an invalid address.
+ * @param hostAddress an int corresponding to the IPv4 address in network byte order
*/
public static InetAddress intToInetAddress(int hostAddress) {
- InetAddress inetAddress;
byte[] addressBytes = { (byte)(0xff & hostAddress),
(byte)(0xff & (hostAddress >> 8)),
(byte)(0xff & (hostAddress >> 16)),
(byte)(0xff & (hostAddress >> 24)) };
try {
- inetAddress = InetAddress.getByAddress(addressBytes);
- } catch(UnknownHostException e) {
- return null;
+ return InetAddress.getByAddress(addressBytes);
+ } catch (UnknownHostException e) {
+ throw new AssertionError();
}
-
- return inetAddress;
}
/**
diff --git a/core/java/android/os/storage/IMountService.java b/core/java/android/os/storage/IMountService.java
index 23ed31f..b9d4711 100644
--- a/core/java/android/os/storage/IMountService.java
+++ b/core/java/android/os/storage/IMountService.java
@@ -603,6 +603,23 @@ public interface IMountService extends IInterface {
}
return _result;
}
+
+ public int encryptStorage(String password) throws RemoteException {
+ Parcel _data = Parcel.obtain();
+ Parcel _reply = Parcel.obtain();
+ int _result;
+ try {
+ _data.writeInterfaceToken(DESCRIPTOR);
+ _data.writeString(password);
+ mRemote.transact(Stub.TRANSACTION_encryptStorage, _data, _reply, 0);
+ _reply.readException();
+ _result = _reply.readInt();
+ } finally {
+ _reply.recycle();
+ _data.recycle();
+ }
+ return _result;
+ }
}
private static final String DESCRIPTOR = "IMountService";
@@ -661,6 +678,8 @@ public interface IMountService extends IInterface {
static final int TRANSACTION_decryptStorage = IBinder.FIRST_CALL_TRANSACTION + 26;
+ static final int TRANSACTION_encryptStorage = IBinder.FIRST_CALL_TRANSACTION + 27;
+
/**
* Cast an IBinder object into an IMountService interface, generating a
* proxy if needed.
@@ -950,6 +969,14 @@ public interface IMountService extends IInterface {
reply.writeInt(result);
return true;
}
+ case TRANSACTION_encryptStorage: {
+ data.enforceInterface(DESCRIPTOR);
+ String password = data.readString();
+ int result = encryptStorage(password);
+ reply.writeNoException();
+ reply.writeInt(result);
+ return true;
+ }
}
return super.onTransact(code, data, reply, flags);
}
@@ -1114,4 +1141,9 @@ public interface IMountService extends IInterface {
* Decrypts any encrypted volumes.
*/
public int decryptStorage(String password) throws RemoteException;
+
+ /**
+ * Encrypts storage.
+ */
+ public int encryptStorage(String password) throws RemoteException;
}
diff --git a/core/java/android/text/format/Formatter.java b/core/java/android/text/format/Formatter.java
index baaa3ce..5ae65df 100644
--- a/core/java/android/text/format/Formatter.java
+++ b/core/java/android/text/format/Formatter.java
@@ -17,32 +17,33 @@
package android.text.format;
import android.content.Context;
+import android.net.NetworkUtils;
/**
* Utility class to aid in formatting common values that are not covered
- * by the standard java.util.Formatter.
+ * by {@link java.util.Formatter}
*/
public final class Formatter {
/**
* Formats a content size to be in the form of bytes, kilobytes, megabytes, etc
- *
+ *
* @param context Context to use to load the localized units
- * @param number size value to be formated
- * @return formated string with the number
+ * @param number size value to be formatted
+ * @return formatted string with the number
*/
public static String formatFileSize(Context context, long number) {
return formatFileSize(context, number, false);
}
-
+
/**
* Like {@link #formatFileSize}, but trying to generate shorter numbers
- * (showing fewer digits of precisin).
+ * (showing fewer digits of precision).
*/
public static String formatShortFileSize(Context context, long number) {
return formatFileSize(context, number, true);
}
-
+
private static String formatFileSize(Context context, long number, boolean shorter) {
if (context == null) {
return "";
@@ -92,21 +93,21 @@ public final class Formatter {
getString(com.android.internal.R.string.fileSizeSuffix,
value, context.getString(suffix));
}
-
+
/**
* Returns a string in the canonical IP format ###.###.###.### from a packed integer containing
* the IP address. The IP address is expected to be in little-endian format (LSB first). That
* is, 0x01020304 will return "4.3.2.1".
- *
- * @param addr the IP address as a packed integer with LSB first.
+ *
+ * @param ipv4Address the IP address as a packed integer with LSB first.
* @return string with canonical IP address format.
+ *
+ * @deprecated this method doesn't support IPv6 addresses. Prefer {@link
+ * java.net.InetAddress#getHostAddress()}, which supports both IPv4 and
+ * IPv6 addresses.
*/
- public static String formatIpAddress(int addr) {
- StringBuffer buf = new StringBuffer();
- buf.append(addr & 0xff).append('.').
- append((addr >>>= 8) & 0xff).append('.').
- append((addr >>>= 8) & 0xff).append('.').
- append((addr >>>= 8) & 0xff);
- return buf.toString();
+ @Deprecated
+ public static String formatIpAddress(int ipv4Address) {
+ return NetworkUtils.intToInetAddress(ipv4Address).getHostAddress();
}
}
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index de1faa2..e246717 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -738,7 +738,8 @@ class BrowserFrame extends Handler {
}
// content://
- } else if (url.startsWith(ANDROID_CONTENT)) {
+ } else if (mSettings.getAllowContentAccess() &&
+ url.startsWith(ANDROID_CONTENT)) {
try {
// Strip off mimetype, for compatibility with ContentLoader.java
// If we don't do this, we can fail to load Gmail attachments,
diff --git a/core/java/android/webkit/FrameLoader.java b/core/java/android/webkit/FrameLoader.java
index 2b44775..0d80302 100644
--- a/core/java/android/webkit/FrameLoader.java
+++ b/core/java/android/webkit/FrameLoader.java
@@ -203,7 +203,8 @@ class FrameLoader {
settings.getAllowFileAccess())).sendToTarget();
}
return true;
- } else if (URLUtil.isContentUrl(url)) {
+ } else if (settings.getAllowContentAccess() &&
+ URLUtil.isContentUrl(url)) {
// Send the raw url to the ContentLoader because it will do a
// permission check and the url has to match.
if (loadListener.isSynchronous()) {
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 6750422..0670c4e 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -215,6 +215,7 @@ public class WebSettings {
private boolean mBuiltInZoomControls = false;
private boolean mDisplayZoomControls = true;
private boolean mAllowFileAccess = true;
+ private boolean mAllowContentAccess = true;
private boolean mLoadWithOverviewMode = false;
private boolean mEnableSmoothTransition = false;
@@ -587,7 +588,9 @@ public class WebSettings {
/**
* Enable or disable file access within WebView. File access is enabled by
- * default.
+ * default. Note that this enables or disables file system access only.
+ * Assets and resources are still accessible using file:///android_asset and
+ * file:///android_res.
*/
public void setAllowFileAccess(boolean allow) {
mAllowFileAccess = allow;
@@ -601,6 +604,22 @@ public class WebSettings {
}
/**
+ * Enable or disable content url access within WebView. Content url access
+ * allows WebView to load content from a content provider installed in the
+ * system. The default is enabled.
+ */
+ public void setAllowContentAccess(boolean allow) {
+ mAllowContentAccess = allow;
+ }
+
+ /**
+ * Returns true if this WebView supports content url access.
+ */
+ public boolean getAllowContentAccess() {
+ return mAllowContentAccess;
+ }
+
+ /**
* Set whether the WebView loads a page with overview mode.
*/
public void setLoadWithOverviewMode(boolean overview) {