Merge into jb-mr1-dev

Change-Id: I1baab28b12364213673ed7992207ad198491f286
This commit is contained in:
Jean-Baptiste Queru
2012-09-25 09:24:39 -07:00
5 changed files with 76 additions and 133 deletions

View File

@@ -18797,7 +18797,7 @@ package android.provider {
method public static int getInt(android.content.ContentResolver, java.lang.String) throws android.provider.Settings.SettingNotFoundException;
method public static long getLong(android.content.ContentResolver, java.lang.String, long);
method public static long getLong(android.content.ContentResolver, java.lang.String) throws android.provider.Settings.SettingNotFoundException;
method public static synchronized java.lang.String getString(android.content.ContentResolver, java.lang.String);
method public static java.lang.String getString(android.content.ContentResolver, java.lang.String);
method public static android.net.Uri getUriFor(java.lang.String);
method public static boolean putFloat(android.content.ContentResolver, java.lang.String, float);
method public static boolean putInt(android.content.ContentResolver, java.lang.String, int);
@@ -18853,7 +18853,7 @@ package android.provider {
method public static int getInt(android.content.ContentResolver, java.lang.String) throws android.provider.Settings.SettingNotFoundException;
method public static long getLong(android.content.ContentResolver, java.lang.String, long);
method public static long getLong(android.content.ContentResolver, java.lang.String) throws android.provider.Settings.SettingNotFoundException;
method public static synchronized java.lang.String getString(android.content.ContentResolver, java.lang.String);
method public static java.lang.String getString(android.content.ContentResolver, java.lang.String);
method public static android.net.Uri getUriFor(java.lang.String);
method public static final boolean isLocationProviderEnabled(android.content.ContentResolver, java.lang.String);
method public static boolean putFloat(android.content.ContentResolver, java.lang.String, float);
@@ -18936,7 +18936,7 @@ package android.provider {
method public static long getLong(android.content.ContentResolver, java.lang.String, long);
method public static long getLong(android.content.ContentResolver, java.lang.String) throws android.provider.Settings.SettingNotFoundException;
method public static deprecated boolean getShowGTalkServiceStatus(android.content.ContentResolver);
method public static synchronized java.lang.String getString(android.content.ContentResolver, java.lang.String);
method public static java.lang.String getString(android.content.ContentResolver, java.lang.String);
method public static android.net.Uri getUriFor(java.lang.String);
method public static boolean putConfiguration(android.content.ContentResolver, android.content.res.Configuration);
method public static boolean putFloat(android.content.ContentResolver, java.lang.String, float);

View File

@@ -764,10 +764,6 @@ public final class Settings {
return true;
}
public boolean putString(ContentResolver cr, String name, String value) {
return putStringForUser(cr, name, value, UserHandle.myUserId());
}
public String getStringForUser(ContentResolver cr, String name, final int userHandle) {
final boolean isSelf = (userHandle == UserHandle.myUserId());
if (isSelf) {
@@ -855,10 +851,6 @@ public final class Settings {
if (c != null) c.close();
}
}
public String getString(ContentResolver cr, String name) {
return getStringForUser(cr, name, UserHandle.myUserId());
}
}
/**
@@ -869,8 +861,17 @@ public final class Settings {
public static final class System extends NameValueTable {
public static final String SYS_PROP_SETTING_VERSION = "sys.settings_system_version";
// Populated lazily, guarded by class object:
private static NameValueCache sNameValueCache = null;
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://" + AUTHORITY + "/system");
private static final NameValueCache sNameValueCache = new NameValueCache(
SYS_PROP_SETTING_VERSION,
CONTENT_URI,
CALL_METHOD_GET_SYSTEM,
CALL_METHOD_PUT_SYSTEM);
private static final HashSet<String> MOVED_TO_SECURE;
static {
@@ -937,28 +938,18 @@ public final class Settings {
MOVED_TO_GLOBAL.add(Settings.Global.MODE_RINGER);
}
private static void lazyInitCache() {
if (sNameValueCache == null) {
sNameValueCache = new NameValueCache(
SYS_PROP_SETTING_VERSION + '_' + UserHandle.myUserId(),
CONTENT_URI,
CALL_METHOD_GET_SYSTEM,
CALL_METHOD_PUT_SYSTEM);
}
}
/**
* Look up a name in the database.
* @param resolver to access the database with
* @param name to look up in the table
* @return the corresponding value, or null if not present
*/
public synchronized static String getString(ContentResolver resolver, String name) {
public static String getString(ContentResolver resolver, String name) {
return getStringForUser(resolver, name, UserHandle.myUserId());
}
/** @hide */
public synchronized static String getStringForUser(ContentResolver resolver, String name,
public static String getStringForUser(ContentResolver resolver, String name,
int userHandle) {
if (MOVED_TO_SECURE.contains(name)) {
Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
@@ -970,7 +961,6 @@ public final class Settings {
+ " to android.provider.Settings.Global, returning read-only value.");
return Global.getStringForUser(resolver, name, userHandle);
}
lazyInitCache();
return sNameValueCache.getStringForUser(resolver, name, userHandle);
}
@@ -998,7 +988,6 @@ public final class Settings {
+ " to android.provider.Settings.Global, value is unchanged.");
return false;
}
lazyInitCache();
return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
}
@@ -1367,12 +1356,6 @@ public final class Settings {
putIntForUser(cr, SHOW_GTALK_SERVICE_STATUS, flag ? 1 : 0, userHandle);
}
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://" + AUTHORITY + "/system");
/**
* @deprecated Use {@link android.provider.Settings.Global#STAY_ON_WHILE_PLUGGED_IN} instead
*/
@@ -2549,8 +2532,18 @@ public final class Settings {
public static final class Secure extends NameValueTable {
public static final String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version";
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://" + AUTHORITY + "/secure");
// Populated lazily, guarded by class object:
private static NameValueCache sNameValueCache = null;
private static final NameValueCache sNameValueCache = new NameValueCache(
SYS_PROP_SETTING_VERSION,
CONTENT_URI,
CALL_METHOD_GET_SECURE,
CALL_METHOD_PUT_SECURE);
private static ILockSettings sLockSettings = null;
@@ -2654,28 +2647,18 @@ public final class Settings {
MOVED_TO_GLOBAL.add(Settings.Global.WTF_IS_FATAL);
}
private static void lazyInitCache() {
if (sNameValueCache == null) {
sNameValueCache = new NameValueCache(
SYS_PROP_SETTING_VERSION + '_' + UserHandle.myUserId(),
CONTENT_URI,
CALL_METHOD_GET_SECURE,
CALL_METHOD_PUT_SECURE);
}
}
/**
* Look up a name in the database.
* @param resolver to access the database with
* @param name to look up in the table
* @return the corresponding value, or null if not present
*/
public synchronized static String getString(ContentResolver resolver, String name) {
public static String getString(ContentResolver resolver, String name) {
return getStringForUser(resolver, name, UserHandle.myUserId());
}
/** @hide */
public synchronized static String getStringForUser(ContentResolver resolver, String name,
public static String getStringForUser(ContentResolver resolver, String name,
int userHandle) {
if (MOVED_TO_GLOBAL.contains(name)) {
Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure"
@@ -2683,21 +2666,23 @@ public final class Settings {
return Global.getStringForUser(resolver, name, userHandle);
}
if (sLockSettings == null) {
sLockSettings = ILockSettings.Stub.asInterface(
(IBinder) ServiceManager.getService("lock_settings"));
sIsSystemProcess = Process.myUid() == Process.SYSTEM_UID;
}
if (sLockSettings != null && !sIsSystemProcess
&& MOVED_TO_LOCK_SETTINGS.contains(name)) {
try {
return sLockSettings.getString(name, "0", userHandle);
} catch (RemoteException re) {
// Fall through
if (MOVED_TO_LOCK_SETTINGS.contains(name)) {
synchronized (Secure.class) {
if (sLockSettings == null) {
sLockSettings = ILockSettings.Stub.asInterface(
(IBinder) ServiceManager.getService("lock_settings"));
sIsSystemProcess = Process.myUid() == Process.SYSTEM_UID;
}
}
if (sLockSettings != null && !sIsSystemProcess) {
try {
return sLockSettings.getString(name, "0", userHandle);
} catch (RemoteException re) {
// Fall through
}
}
}
lazyInitCache();
return sNameValueCache.getStringForUser(resolver, name, userHandle);
}
@@ -2720,7 +2705,6 @@ public final class Settings {
+ " to android.provider.Settings.Global");
return Global.putStringForUser(resolver, name, value, userHandle);
}
lazyInitCache();
return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
}
@@ -3000,12 +2984,6 @@ public final class Settings {
return putStringForUser(cr, name, Float.toString(value), userHandle);
}
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://" + AUTHORITY + "/secure");
/**
* @deprecated Use {@link android.provider.Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}
* instead
@@ -5765,17 +5743,11 @@ public final class Settings {
// Populated lazily, guarded by class object:
private static NameValueCache sNameValueCache = null;
private static void lazyInitCache() {
if (sNameValueCache == null) {
sNameValueCache = new NameValueCache(
SYS_PROP_SETTING_VERSION,
CONTENT_URI,
CALL_METHOD_GET_GLOBAL,
CALL_METHOD_PUT_GLOBAL);
}
}
private static NameValueCache sNameValueCache = new NameValueCache(
SYS_PROP_SETTING_VERSION,
CONTENT_URI,
CALL_METHOD_GET_GLOBAL,
CALL_METHOD_PUT_GLOBAL);
/**
* Look up a name in the database.
@@ -5783,14 +5755,13 @@ public final class Settings {
* @param name to look up in the table
* @return the corresponding value, or null if not present
*/
public synchronized static String getString(ContentResolver resolver, String name) {
public static String getString(ContentResolver resolver, String name) {
return getStringForUser(resolver, name, UserHandle.myUserId());
}
/** @hide */
public synchronized static String getStringForUser(ContentResolver resolver, String name,
public static String getStringForUser(ContentResolver resolver, String name,
int userHandle) {
lazyInitCache();
return sNameValueCache.getStringForUser(resolver, name, userHandle);
}
@@ -5809,7 +5780,6 @@ public final class Settings {
/** @hide */
public static boolean putStringForUser(ContentResolver resolver,
String name, String value, int userHandle) {
lazyInitCache();
if (LOCAL_LOGV) {
Log.v(TAG, "Global.putString(name=" + name + ", value=" + value
+ " for " + userHandle);

View File

@@ -315,10 +315,10 @@ public class SettingsProvider extends ContentProvider {
String property = null, table = uri.getPathSegments().get(0);
final boolean isGlobal = table.equals(TABLE_GLOBAL);
if (table.equals(TABLE_SYSTEM)) {
property = Settings.System.SYS_PROP_SETTING_VERSION + '_' + userHandle;
property = Settings.System.SYS_PROP_SETTING_VERSION;
backedUpDataChanged = true;
} else if (table.equals(TABLE_SECURE)) {
property = Settings.Secure.SYS_PROP_SETTING_VERSION + '_' + userHandle;
property = Settings.Secure.SYS_PROP_SETTING_VERSION;
backedUpDataChanged = true;
} else if (isGlobal) {
property = Settings.Global.SYS_PROP_SETTING_VERSION; // this one is global
@@ -447,11 +447,6 @@ public class SettingsProvider extends ContentProvider {
sSystemCaches.delete(userHandle);
sSecureCaches.delete(userHandle);
sKnownMutationsInFlight.delete(userHandle);
String property = Settings.System.SYS_PROP_SETTING_VERSION + '_' + userHandle;
SystemProperties.set(property, "");
property = Settings.Secure.SYS_PROP_SETTING_VERSION + '_' + userHandle;
SystemProperties.set(property, "");
}
}

View File

@@ -706,7 +706,7 @@ public class ActiveServices {
if (DEBUG_SERVICE) Slog.v(TAG, "retrieveServiceLocked: " + service
+ " type=" + resolvedType + " callingUid=" + callingUid);
userId = mAm.handleIncomingUserLocked(callingPid, callingUid, userId,
userId = mAm.handleIncomingUser(callingPid, callingUid, userId,
false, true, "service", null);
if (service.getComponent() != null) {

View File

@@ -2448,7 +2448,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String resultWho, int requestCode, int startFlags,
String profileFile, ParcelFileDescriptor profileFd, Bundle options, int userId) {
enforceNotIsolatedCaller("startActivity");
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivity", null);
return mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags, profileFile, profileFd,
@@ -2460,7 +2460,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String resultWho, int requestCode, int startFlags, String profileFile,
ParcelFileDescriptor profileFd, Bundle options, int userId) {
enforceNotIsolatedCaller("startActivityAndWait");
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityAndWait", null);
WaitResult res = new WaitResult();
mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
@@ -2474,7 +2474,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String resultWho, int requestCode, int startFlags, Configuration config,
Bundle options, int userId) {
enforceNotIsolatedCaller("startActivityWithConfig");
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityWithConfig", null);
int ret = mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags,
@@ -2613,7 +2613,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, Bundle options, int userId) {
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityInPackage", null);
int ret = mMainStack.startActivityMayWait(null, uid, intent, resolvedType,
@@ -2634,7 +2634,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options, int userId) {
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityInPackage", null);
int ret = mMainStack.startActivities(null, uid, intents, resolvedTypes, resultTo,
options, userId);
@@ -3460,7 +3460,7 @@ public final class ActivityManagerService extends ActivityManagerNative
enforceNotIsolatedCaller("clearApplicationUserData");
int uid = Binder.getCallingUid();
int pid = Binder.getCallingPid();
userId = handleIncomingUserLocked(pid, uid,
userId = handleIncomingUser(pid, uid,
userId, false, true, "clearApplicationUserData", null);
long callingId = Binder.clearCallingIdentity();
try {
@@ -3516,7 +3516,7 @@ public final class ActivityManagerService extends ActivityManagerNative
throw new SecurityException(msg);
}
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, true, true, "killBackgroundProcesses", null);
long callingId = Binder.clearCallingIdentity();
try {
@@ -3591,7 +3591,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Slog.w(TAG, msg);
throw new SecurityException(msg);
}
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, true, true, "forceStopPackage", null);
long callingId = Binder.clearCallingIdentity();
try {
@@ -4596,7 +4596,7 @@ public final class ActivityManagerService extends ActivityManagerNative
synchronized(this) {
int callingUid = Binder.getCallingUid();
int origUserId = userId;
userId = handleIncomingUserLocked(Binder.getCallingPid(), callingUid, userId,
userId = handleIncomingUser(Binder.getCallingPid(), callingUid, userId,
type == ActivityManager.INTENT_SENDER_BROADCAST, true,
"getIntentSender", null);
if (origUserId == UserHandle.USER_CURRENT) {
@@ -5756,26 +5756,8 @@ public final class ActivityManagerService extends ActivityManagerNative
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
int flags, int userId) {
final int callingUid = Binder.getCallingUid();
if (userId != UserHandle.getCallingUserId()) {
// Check if the caller is holding permissions for cross-user requests.
if (checkComponentPermission(
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Binder.getCallingPid(), callingUid, -1, true)
!= PackageManager.PERMISSION_GRANTED) {
String msg = "Permission Denial: "
+ "Request to get recent tasks for user " + userId
+ " but is calling from user " + UserHandle.getUserId(callingUid)
+ "; this requires "
+ android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
Slog.w(TAG, msg);
throw new SecurityException(msg);
} else {
if (userId == UserHandle.USER_CURRENT) {
userId = mCurrentUserId;
}
}
}
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "getRecentTasks", null);
synchronized (this) {
enforceCallingPermission(android.Manifest.permission.GET_TASKS,
@@ -6679,7 +6661,7 @@ public final class ActivityManagerService extends ActivityManagerNative
throw new SecurityException(msg);
}
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "getContentProvider", null);
return getContentProviderImpl(caller, name, null, stable, userId);
}
@@ -6688,7 +6670,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String name, int userId, IBinder token) {
enforceCallingPermission(android.Manifest.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY,
"Do not have permission in call getContentProviderExternal()");
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "getContentProvider", null);
return getContentProviderExternalUnchecked(name, token, userId);
}
@@ -6953,7 +6935,7 @@ public final class ActivityManagerService extends ActivityManagerNative
*/
public String getProviderMimeType(Uri uri, int userId) {
enforceNotIsolatedCaller("getProviderMimeType");
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, false, true, "getProviderMimeType", null);
final String name = uri.getAuthority();
final long ident = Binder.clearCallingIdentity();
@@ -10926,14 +10908,6 @@ public final class ActivityManagerService extends ActivityManagerNative
public int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll,
boolean requireFull, String name, String callerPackage) {
synchronized(this) {
return handleIncomingUserLocked(callingPid, callingUid, userId, allowAll,
requireFull, name, callerPackage);
}
}
int handleIncomingUserLocked(int callingPid, int callingUid, int userId, boolean allowAll,
boolean requireFull, String name, String callerPackage) {
final int callingUserId = UserHandle.getUserId(callingUid);
if (callingUserId != userId) {
if (callingUid != 0 && callingUid != Process.SYSTEM_UID) {
@@ -10974,6 +10948,10 @@ public final class ActivityManagerService extends ActivityManagerNative
}
if (userId == UserHandle.USER_CURRENT
|| userId == UserHandle.USER_CURRENT_OR_SELF) {
// Note that we may be accessing this outside of a lock...
// shouldn't be a big deal, if this is being called outside
// of a locked context there is intrinsically a race with
// the value the caller will receive and someone else changing it.
userId = mCurrentUserId;
}
if (!allowAll && userId < 0) {
@@ -11280,7 +11258,7 @@ public final class ActivityManagerService extends ActivityManagerNative
callingPid = Binder.getCallingPid();
}
userId = this.handleIncomingUserLocked(callingPid, callingUid, userId,
userId = this.handleIncomingUser(callingPid, callingUid, userId,
true, true, "registerReceiver", callerPackage);
List allSticky = null;
@@ -11515,7 +11493,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Slog.w(TAG, "Broadcast " + intent + " not ordered but result callback requested!");
}
userId = handleIncomingUserLocked(callingPid, callingUid, userId,
userId = handleIncomingUser(callingPid, callingUid, userId,
true, false, "broadcast", callerPackage);
// Make sure that the user who is receiving this broadcast is started.
@@ -11928,7 +11906,7 @@ public final class ActivityManagerService extends ActivityManagerNative
throw new IllegalArgumentException("File descriptors passed in Intent");
}
userId = handleIncomingUserLocked(Binder.getCallingPid(),
userId = handleIncomingUser(Binder.getCallingPid(),
Binder.getCallingUid(), userId, true, false, "removeStickyBroadcast", null);
synchronized(this) {
@@ -12016,7 +11994,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String profileFile, int flags, Bundle arguments,
IInstrumentationWatcher watcher, int userId) {
enforceNotIsolatedCaller("startInstrumentation");
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, false, true, "startInstrumentation", null);
// Refuse possible leaked file descriptors
if (arguments != null && arguments.hasFileDescriptors()) {
@@ -13862,7 +13840,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
private ProcessRecord findProcessLocked(String process, int userId, String callName) {
userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, true, true, callName, null);
ProcessRecord proc = null;
try {