Merge changes Ib8b18f1b,I0d799d82,Ia6222322

* changes:
  Always give ContentResolver a valid Context.
  Define failed connections column, and reset.
  Add method to get process group.
This commit is contained in:
Jeff Sharkey
2013-01-18 02:44:47 +00:00
committed by Android (Google) Code Review
8 changed files with 44 additions and 11 deletions

View File

@@ -21512,6 +21512,7 @@ package android.test.mock {
public class MockContentResolver extends android.content.ContentResolver { public class MockContentResolver extends android.content.ContentResolver {
ctor public MockContentResolver(); ctor public MockContentResolver();
ctor public MockContentResolver(android.content.Context);
method public void addProvider(java.lang.String, android.content.ContentProvider); method public void addProvider(java.lang.String, android.content.ContentProvider);
} }

View File

@@ -187,7 +187,8 @@ public final class ActivityThread {
= new ArrayList<Application>(); = new ArrayList<Application>();
// set of instantiated backup agents, keyed by package name // set of instantiated backup agents, keyed by package name
final HashMap<String, BackupAgent> mBackupAgents = new HashMap<String, BackupAgent>(); final HashMap<String, BackupAgent> mBackupAgents = new HashMap<String, BackupAgent>();
static final ThreadLocal<ActivityThread> sThreadLocal = new ThreadLocal<ActivityThread>(); /** Reference to singleton {@link ActivityThread} */
private static ActivityThread sCurrentActivityThread;
Instrumentation mInstrumentation; Instrumentation mInstrumentation;
String mInstrumentationAppDir = null; String mInstrumentationAppDir = null;
String mInstrumentationAppLibraryDir = null; String mInstrumentationAppLibraryDir = null;
@@ -1564,7 +1565,7 @@ public final class ActivityThread {
} }
public static ActivityThread currentActivityThread() { public static ActivityThread currentActivityThread() {
return sThreadLocal.get(); return sCurrentActivityThread;
} }
public static String currentPackageName() { public static String currentPackageName() {
@@ -4894,7 +4895,7 @@ public final class ActivityThread {
} }
private void attach(boolean system) { private void attach(boolean system) {
sThreadLocal.set(this); sCurrentActivityThread = this;
mSystemThread = system; mSystemThread = system;
if (!system) { if (!system) {
ViewRootImpl.addFirstDrawHandler(new Runnable() { ViewRootImpl.addFirstDrawHandler(new Runnable() {

View File

@@ -1085,6 +1085,7 @@ public class DownloadManager {
values.put(Downloads.Impl.COLUMN_TOTAL_BYTES, -1); values.put(Downloads.Impl.COLUMN_TOTAL_BYTES, -1);
values.putNull(Downloads.Impl._DATA); values.putNull(Downloads.Impl._DATA);
values.put(Downloads.Impl.COLUMN_STATUS, Downloads.Impl.STATUS_PENDING); values.put(Downloads.Impl.COLUMN_STATUS, Downloads.Impl.STATUS_PENDING);
values.put(Downloads.Impl.COLUMN_FAILED_CONNECTIONS, 0);
mResolver.update(mBaseUri, values, getWhereClauseForIds(ids), getWhereArgsForIds(ids)); mResolver.update(mBaseUri, values, getWhereClauseForIds(ids), getWhereArgsForIds(ids));
} }

View File

@@ -20,6 +20,7 @@ import dalvik.system.CloseGuard;
import android.accounts.Account; import android.accounts.Account;
import android.app.ActivityManagerNative; import android.app.ActivityManagerNative;
import android.app.ActivityThread;
import android.app.AppGlobals; import android.app.AppGlobals;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetFileDescriptor; import android.content.res.AssetFileDescriptor;
@@ -206,8 +207,8 @@ public abstract class ContentResolver {
private final Random mRandom = new Random(); // guarded by itself private final Random mRandom = new Random(); // guarded by itself
public ContentResolver(Context context) { public ContentResolver(Context context) {
mContext = context; mContext = context != null ? context : ActivityThread.currentApplication();
mPackageName = context.getPackageName(); mPackageName = mContext.getPackageName();
} }
/** @hide */ /** @hide */

View File

@@ -806,7 +806,15 @@ public class Process {
*/ */
public static final native void setProcessGroup(int pid, int group) public static final native void setProcessGroup(int pid, int group)
throws IllegalArgumentException, SecurityException; throws IllegalArgumentException, SecurityException;
/**
* Return the scheduling group of requested process.
*
* @hide
*/
public static final native int getProcessGroup(int pid)
throws IllegalArgumentException, SecurityException;
/** /**
* Set the priority of the calling thread, based on Linux priorities. See * Set the priority of the calling thread, based on Linux priorities. See
* {@link #setThreadPriority(int, int)} for more information. * {@link #setThreadPriority(int, int)} for more information.

View File

@@ -407,6 +407,9 @@ public final class Downloads {
*/ */
public static final String COLUMN_LAST_UPDATESRC = "lastUpdateSrc"; public static final String COLUMN_LAST_UPDATESRC = "lastUpdateSrc";
/** The column that is used to count retries */
public static final String COLUMN_FAILED_CONNECTIONS = "numfailed";
/** /**
* default value for {@link #COLUMN_LAST_UPDATESRC}. * default value for {@link #COLUMN_LAST_UPDATESRC}.
* This value is used when this column's value is not relevant. * This value is used when this column's value is not relevant.

View File

@@ -268,6 +268,15 @@ void android_os_Process_setProcessGroup(JNIEnv* env, jobject clazz, int pid, jin
closedir(d); closedir(d);
} }
jint android_os_Process_getProcessGroup(JNIEnv* env, jobject clazz, jint pid)
{
SchedPolicy sp;
if (get_sched_policy(pid, &sp) != 0) {
signalExceptionForGroupError(env, errno);
}
return (int) sp;
}
static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz, jboolean bgOk) { static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz, jboolean bgOk) {
// Establishes the calling thread as illegal to put into the background. // Establishes the calling thread as illegal to put into the background.
// Typically used only for the system process's main looper. // Typically used only for the system process's main looper.
@@ -991,7 +1000,8 @@ static const JNINativeMethod methods[] = {
{"setThreadPriority", "(I)V", (void*)android_os_Process_setCallingThreadPriority}, {"setThreadPriority", "(I)V", (void*)android_os_Process_setCallingThreadPriority},
{"getThreadPriority", "(I)I", (void*)android_os_Process_getThreadPriority}, {"getThreadPriority", "(I)I", (void*)android_os_Process_getThreadPriority},
{"setThreadGroup", "(II)V", (void*)android_os_Process_setThreadGroup}, {"setThreadGroup", "(II)V", (void*)android_os_Process_setThreadGroup},
{"setProcessGroup", "(II)V", (void*)android_os_Process_setProcessGroup}, {"setProcessGroup", "(II)V", (void*)android_os_Process_setProcessGroup},
{"getProcessGroup", "(I)I", (void*)android_os_Process_getProcessGroup},
{"setOomAdj", "(II)Z", (void*)android_os_Process_setOomAdj}, {"setOomAdj", "(II)Z", (void*)android_os_Process_setOomAdj},
{"setArgV0", "(Ljava/lang/String;)V", (void*)android_os_Process_setArgV0}, {"setArgV0", "(Ljava/lang/String;)V", (void*)android_os_Process_setArgV0},
{"setUid", "(I)I", (void*)android_os_Process_setUid}, {"setUid", "(I)I", (void*)android_os_Process_setUid},

View File

@@ -54,12 +54,20 @@ import java.util.Map;
public class MockContentResolver extends ContentResolver { public class MockContentResolver extends ContentResolver {
Map<String, ContentProvider> mProviders; Map<String, ContentProvider> mProviders;
/* /**
* Creates a local map of providers. This map is used instead of the global map when an * Creates a local map of providers. This map is used instead of the global
* API call tries to acquire a provider. * map when an API call tries to acquire a provider.
*/ */
public MockContentResolver() { public MockContentResolver() {
super(null); this(null);
}
/**
* Creates a local map of providers. This map is used instead of the global
* map when an API call tries to acquire a provider.
*/
public MockContentResolver(Context context) {
super(context);
mProviders = Maps.newHashMap(); mProviders = Maps.newHashMap();
} }