merge in jb-mr1-release history after reset to jb-mr1-dev
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationVerifier.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationVerifier.java
index fd226a6..e3f58c3 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationVerifier.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationVerifier.java
@@ -58,6 +58,14 @@
             long delta = timestamp - mLastActiveTimestamp;
             mLastActiveTimestamp = timestamp;
 
+            if (location.getAccuracy() <= 0.0) {
+                fail(mProvider + " location has invalid accuracy: " + location.getAccuracy());
+            }
+            if (location.getElapsedRealtimeNano() <= 0) {
+                fail(mProvider + " location has invalid elapsed realtime: " +
+                        location.getElapsedRealtimeNano());
+            }
+
             if (mNumActiveUpdates != 1 && delta < mMinActiveInterval) {
                 fail(mProvider + " location updated too fast: " + delta + "ms < " +
                         mMinActiveInterval + "ms");
@@ -100,6 +108,14 @@
             long delta = timestamp - mLastPassiveTimestamp;
             mLastPassiveTimestamp = timestamp;
 
+            if (location.getAccuracy() <= 0.0) {
+                fail(mProvider + " location has invalid accuracy: " + location.getAccuracy());
+            }
+            if (location.getElapsedRealtimeNano() <= 0) {
+                fail(mProvider + " location has invalid elapsed realtime: " +
+                        location.getElapsedRealtimeNano());
+            }
+
             if (mNumPassiveUpdates != 1 && delta < mMinPassiveInterval) {
                 fail("passive " + mProvider + " location updated too fast: " + delta + "ms < " +
                         mMinPassiveInterval + "ms");
diff --git a/tests/tests/location/src/android/location/cts/LocationManagerTest.java b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
index 008960e..0fc9b4d 100755
--- a/tests/tests/location/src/android/location/cts/LocationManagerTest.java
+++ b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
@@ -33,6 +33,7 @@
 import android.os.Bundle;
 import android.os.HandlerThread;
 import android.os.Looper;
+import android.os.SystemClock;
 import android.provider.Settings;
 import android.test.InstrumentationTestCase;
 
@@ -53,6 +54,8 @@
 
     private static final String UNKNOWN_PROVIDER_NAME = "unknown_provider";
 
+    private static final String FUSED_PROVIDER_NAME = "fused";
+
     private LocationManager mManager;
 
     private Context mContext;
@@ -453,7 +456,7 @@
         i.setAction("android.location.cts.TEST_GET_GPS_STATUS_ACTION");
         PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, PendingIntent.FLAG_ONE_SHOT);
 
-        mManager.addProximityAlert(0, 0, 0, 5000, pi);
+        mManager.addProximityAlert(0, 0, 1.0f, 5000, pi);
         mManager.removeProximityAlert(pi);
     }
 
@@ -619,12 +622,17 @@
      * @param expiration - expiration of proximity alert
      */
     private void doTestEnterProximity(long expiration) throws Exception {
+        // need to mock the fused location provider for proximity tests
+        mockFusedLocation();
+
         // update location to outside proximity range
-        updateLocation(30, 30);
+        updateLocation(FUSED_PROVIDER_NAME, 30, 30);
         registerProximityListener(0, 0, 1000, expiration);
-        updateLocation(0, 0);
+        updateLocation(FUSED_PROVIDER_NAME, 0, 0);
         waitForReceiveBroadcast();
         assertProximityType(true);
+
+        unmockFusedLocation();
     }
 
     private void registerIntentReceiver() {
@@ -675,8 +683,9 @@
         Location location = new Location(providerName);
         location.setLatitude(latitude);
         location.setLongitude(longitude);
-
+        location.setAccuracy(1.0f);
         location.setTime(java.lang.System.currentTimeMillis());
+        location.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano());
         mManager.setTestProviderLocation(providerName, location);
     }
 
@@ -684,6 +693,14 @@
         updateLocation(TEST_MOCK_PROVIDER_NAME, latitude, longitude);
     }
 
+    private void mockFusedLocation() {
+        addTestProvider(FUSED_PROVIDER_NAME);
+    }
+
+    private void unmockFusedLocation() {
+        mManager.removeTestProvider(FUSED_PROVIDER_NAME);
+    }
+
     /**
      * Helper class that receives a proximity intent and notifies the main class
      * when received
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index 51f7e7e..8ea02ae 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -165,6 +165,13 @@
         assertFalse(f.canRead());
         assertFalse(f.canWrite());
         assertFalse(f.canExecute());
+
+        FileUtils.FileStatus status = new FileUtils.FileStatus();
+        if (f.exists()
+                && FileUtils.getFileStatus(f.getAbsolutePath(), status, true)) {
+            assertEquals("nfc", FileUtils.getUserName(status.uid));
+            assertEquals("nfc", FileUtils.getGroupName(status.gid));
+        }
     }
 
     @MediumTest
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index 1bb79b3..cdfac28 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -14,18 +14,11 @@
 
 LOCAL_PATH := $(call my-dir)
 
-define all-src-files
-$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find src -name '*.java'))
-endef
-
 # buildutil java library
 # ============================================================
 include $(CLEAR_VARS)
 
-LOCAL_TEST_TYPE := vmHostTest
-LOCAL_JAR_PATH := android.core.vm-tests-tf.jar
-
-LOCAL_SRC_FILES := $(call all-src-files)
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_MODULE := cts-tf-dalvik-buildutil
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
@@ -36,77 +29,37 @@
 
 include $(BUILD_HOST_JAVA_LIBRARY)
 
-$(LOCAL_BUILT_MODULE): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes
+# Buid android.core.vm-tests-tf.jar
+# ============================================================
+#
+intermediates := $(call intermediates-dir-for,JAVA_LIBRARIES,vm-tests-tf,HOST)
+vmteststf_jar := $(intermediates)/android.core.vm-tests-tf.jar
+vmteststf_dep_jars := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar dasm.jar dx.jar cfassembler.jar junit.jar)
+$(vmteststf_jar): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
+$(vmteststf_jar): PRIVATE_LIB_FOLDER := $(LOCAL_PATH)/lib
+$(vmteststf_jar): PRIVATE_INTERMEDIATES_CLASSES := $(call intermediates-dir-for,JAVA_LIBRARIES,cts-tf-dalvik-buildutil,HOST)/classes
+$(vmteststf_jar): PRIVATE_INTERMEDIATES := $(intermediates)/tests
+$(vmteststf_jar): PRIVATE_INTERMEDIATES_DEXCORE_JAR := $(intermediates)/tests/dot/junit/dexcore.jar
+$(vmteststf_jar): PRIVATE_INTERMEDIATES_MAIN_FILES := $(intermediates)/main_files
+$(vmteststf_jar): PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES := $(intermediates)/hostjunit_files
+$(vmteststf_jar): PRIVATE_CLASS_PATH := $(subst $(space),:,$(vmteststf_dep_jars)):$(HOST_JDK_TOOLS_JAR)
+$(vmteststf_jar) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
+	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
+	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
+	# generated and compile the host side junit tests
+	@echo "Write generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
+	$(hide) java -cp $(PRIVATE_CLASS_PATH) util.build.BuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
+		$(HOST_OUT_JAVA_LIBRARIES)/cts-tf-dalvik-buildutil.jar:$(PRIVATE_LIB_FOLDER)/junit.jar:$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar \
+		$(PRIVATE_INTERMEDIATES_MAIN_FILES) $(PRIVATE_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
+	@echo "Generate $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)"
+	$(hide) jar -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar \
+		$(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class)
+	$(hide) $(DX) -JXms16M -JXmx768M --dex --output=$(PRIVATE_INTERMEDIATES_DEXCORE_JAR) \
+		$(if $(NO_OPTIMIZE_DX), --no-optimize) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
+	$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../android.core.vm-tests-tf.jar .
+	$(hide) cd $(dir $@) && zip -q -r android.core.vm-tests-tf.jar tests
 
-TF_BUILD_UTIL_INTERMEDIATES_CLASSES := $(intermediates)/classes
-
-include $(CLEAR_VARS)
-
-LOCAL_UNINSTALLABLE_MODULE := true
-LOCAL_IS_HOST_MODULE := true
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_MODULE := vm-tests-tf
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-GENERATED_FILES:=$(intermediates)/tests
-
-$(LOCAL_BUILT_MODULE): $(GENERATED_FILES)
-
-colon:= :
-empty:=
-space:= $(empty) $(empty)
-
-
-$(GENERATED_FILES): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
-$(GENERATED_FILES): PRIVATE_LIB_FOLDER := $(LOCAL_PATH)/lib
-$(GENERATED_FILES): PRIVATE_INTERMEDIATES := $(intermediates)/tests
-$(GENERATED_FILES): PRIVATE_INTERMEDIATES_MAIN_FILES := $(intermediates)/main_files
-$(GENERATED_FILES): PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES := $(intermediates)/hostjunit_files
-$(GENERATED_FILES): $(HOST_OUT_JAVA_LIBRARIES)/cts-tf-dalvik-buildutil.jar $(HOST_OUT_JAVA_LIBRARIES)/dasm.jar $(HOST_OUT_JAVA_LIBRARIES)/dx.jar $(HOST_OUT_JAVA_LIBRARIES)/cfassembler.jar $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
-
-	$(hide) mkdir -p $@
-	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit
-# generated and compile the host side junit tests
-	$(hide) java -cp $(subst $(space),$(colon),$^):$(HOST_JDK_TOOLS_JAR) util.build.BuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) $<:$(PRIVATE_LIB_FOLDER)/junit.jar:$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar $(PRIVATE_INTERMEDIATES_MAIN_FILES) $(TF_BUILD_UTIL_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
-	@echo "wrote generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
-INSTALLED_TESTS := $(dir $(LOCAL_BUILT_MODULE))../cts_dalviktests_tf/timestamp
-
-$(LOCAL_BUILT_MODULE):  $(INSTALLED_TESTS)
-
-$(INSTALLED_TESTS): PRIVATE_INTERMEDIATES := $(intermediates)/tests
-$(INSTALLED_TESTS): $(GENERATED_FILES) $(GENERATED_FILES)/dot/junit/dexcore.jar
-	$(hide) mkdir -p $(dir $@)tests
-	$(hide) $(ACP) -r $(PRIVATE_INTERMEDIATES)/dot $(dir $@)tests
-	@touch $@
-
-$(intermediates)/android.core.vm-tests-tf.jar: PRIVATE_INTERMEDIATES := $(intermediates)
-$(intermediates)/android.core.vm-tests-tf.jar: $(INSTALLED_TESTS)
-	$(hide) cd $(PRIVATE_INTERMEDIATES)/hostjunit_files/classes && \
-	zip -q -r ../../android.core.vm-tests-tf.jar . && \
-	cd -
-	$(hide) cd $(PRIVATE_INTERMEDIATES) && \
-	zip -q -r android.core.vm-tests-tf.jar tests && \
-	cd -
-	
-
-define get-class-path
-	$(TF_BUILD_UTIL_INTERMEDIATES_CLASSES)/$(strip $(1))
-endef
-
-define dex-classes
-	@mkdir -p $(dir $@)
-	@jar -cf $(dir $@)/$(notdir $@).jar $(addprefix -C $(1) ,$(2))
-	$(hide) $(DX) -JXms16M -JXmx768M \
-    --dex --output=$@ \
-    $(if $(NO_OPTIMIZE_DX), \
-        --no-optimize) \
-    $(dir $@)/$(notdir $@).jar
-    @rm -f $(dir $@)/$(notdir $@).jar
-endef
-
-$(call get-class-path,dot/junit/DxUtil.class) $(call get-class-path,dot/junit/DxAbstractMain.class):  $(HOST_OUT_JAVA_LIBRARIES)/cts-tf-dalvik-buildutil.jar $(DX)
-
-$(GENERATED_FILES)/dot/junit/dexcore.jar: $(call get-class-path,dot/junit/DxUtil.class) $(call get-class-path,dot/junit/DxAbstractMain.class)
-	$(call dex-classes,$(TF_BUILD_UTIL_INTERMEDIATES_CLASSES),dot/junit/DxUtil.class dot/junit/DxAbstractMain.class)
+# Clean up temp vars
+intermediates :=
+vmteststf_jar :=
+vmteststf_dep_jars :=