Merge tag 'android-6.0.1_r3' into 601r3

Android 6.0.1 release 3

* tag 'android-6.0.1_r3':
  Update the Connectivity debug app to the multinetwork API.
  Update build tools rev to <API>.0.2. DO NOT MERGE.
  Fix llvm-rs-cc.exe crash for windows
  Update system images to revision 4

Change-Id: Ie1d2d478b1e36a32ee32d5a77365f6cb9e726d8e
diff --git a/apps/Development/res/layout/connectivity.xml b/apps/Development/res/layout/connectivity.xml
index 00ba508..8de23da 100644
--- a/apps/Development/res/layout/connectivity.xml
+++ b/apps/Development/res/layout/connectivity.xml
@@ -248,27 +248,27 @@
       android:paddingTop="4dip"
       android:layout_width="match_parent"
       android:layout_height="wrap_content">
-        <Button android:id="@+id/start_mms"
+        <Button android:id="@+id/request_mms"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
-          android:text="@string/start_mms" />
-        <Button android:id="@+id/stop_mms"
+          android:text="@string/request_mms" />
+        <Button android:id="@+id/release_mms"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
-          android:text="@string/stop_mms" />
+          android:text="@string/release_mms" />
     </LinearLayout>
     <LinearLayout
       android:orientation="horizontal"
       android:layout_width="match_parent"
       android:layout_height="wrap_content">
-        <Button android:id="@+id/start_hipri"
+        <Button android:id="@+id/request_cell"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
-          android:text="@string/start_hipri" />
-        <Button android:id="@+id/stop_hipri"
+          android:text="@string/request_cell" />
+        <Button android:id="@+id/release_cell"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
-          android:text="@string/stop_hipri" />
+          android:text="@string/release_cell" />
     </LinearLayout>
     <LinearLayout
       android:orientation="horizontal"
diff --git a/apps/Development/res/values/strings.xml b/apps/Development/res/values/strings.xml
index 3ef8845..ed42725 100644
--- a/apps/Development/res/values/strings.xml
+++ b/apps/Development/res/values/strings.xml
@@ -40,10 +40,10 @@
     <string name="stop_tdls">Stop TDLS</string>
     <string name="mac_tdls"> IP/MAC: </string>
 
-    <string name="start_mms">Start MMS</string>
-    <string name="stop_mms">Stop MMS</string>
-    <string name="start_hipri">Start HiPri</string>
-    <string name="stop_hipri">Stop HiPri</string>
+    <string name="request_mms">Request MMS</string>
+    <string name="release_mms">Release MMS</string>
+    <string name="request_cell">Request cell</string>
+    <string name="release_cell">Release cell</string>
     <string name="crash">CRASH</string>
     <string name="report_all_bad">Report all bad</string>
 
diff --git a/apps/Development/src/com/android/development/Connectivity.java b/apps/Development/src/com/android/development/Connectivity.java
index 0f0030f..21bf07c 100644
--- a/apps/Development/src/com/android/development/Connectivity.java
+++ b/apps/Development/src/com/android/development/Connectivity.java
@@ -287,6 +287,56 @@
     }
     private DevToolsNetworkCallback mCallback;
 
+    private class RequestableNetwork {
+        private final NetworkRequest mRequest;
+        private final int mRequestButton, mReleaseButton;
+        private NetworkCallback mCallback;
+
+        public RequestableNetwork(NetworkRequest request, int requestButton, int releaseButton) {
+            mRequest = request;
+            mRequestButton = requestButton;
+            mReleaseButton = releaseButton;
+        }
+
+        public void setRequested(boolean requested) {
+            findViewById(mRequestButton).setEnabled(!requested);
+            findViewById(mReleaseButton).setEnabled(requested);
+        }
+
+        public void request() {
+            if (mCallback == null) {
+                mCallback = new NetworkCallback();
+                mCm.requestNetwork(mRequest, mCallback);
+                setRequested(true);
+            }
+        }
+
+        public void release() {
+            if (mCallback != null) {
+                mCm.unregisterNetworkCallback(mCallback);
+                mCallback = null;
+                setRequested(false);
+            }
+        }
+    }
+
+    private final RequestableNetwork mMmsNetwork = new RequestableNetwork(
+            new NetworkRequest.Builder()
+                    .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS)
+                    .build(),
+            R.id.request_mms,
+            R.id.release_mms);
+
+    private final RequestableNetwork mCellNetwork = new RequestableNetwork(
+            new NetworkRequest.Builder()
+                    .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
+                    .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
+                    .build(),
+            R.id.request_cell,
+            R.id.release_cell);
+
+    final NetworkRequest mEmptyRequest = new NetworkRequest.Builder().clearCapabilities().build();
+
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
@@ -336,10 +386,10 @@
         findViewById(R.id.startTdls).setOnClickListener(mClickListener);
         findViewById(R.id.stopTdls).setOnClickListener(mClickListener);
 
-        findViewById(R.id.start_mms).setOnClickListener(mClickListener);
-        findViewById(R.id.stop_mms).setOnClickListener(mClickListener);
-        findViewById(R.id.start_hipri).setOnClickListener(mClickListener);
-        findViewById(R.id.stop_hipri).setOnClickListener(mClickListener);
+        findViewById(R.id.request_mms).setOnClickListener(mClickListener);
+        findViewById(R.id.release_mms).setOnClickListener(mClickListener);
+        findViewById(R.id.request_cell).setOnClickListener(mClickListener);
+        findViewById(R.id.release_cell).setOnClickListener(mClickListener);
         findViewById(R.id.report_all_bad).setOnClickListener(mClickListener);
         findViewById(R.id.crash).setOnClickListener(mClickListener);
 
@@ -353,24 +403,25 @@
         findViewById(R.id.default_socket).setOnClickListener(mClickListener);
         findViewById(R.id.link_stats).setOnClickListener(mClickListener);
 
+        mCellNetwork.setRequested(false);
+        mMmsNetwork.setRequested(false);
+
         registerReceiver(mReceiver, new IntentFilter(CONNECTIVITY_TEST_ALARM));
 
         mLinkStatsResults = (TextView)findViewById(R.id.stats);
         mLinkStatsResults.setVisibility(View.VISIBLE);
 
-        NetworkRequest.Builder builder = new NetworkRequest.Builder();
-        for (int i = 0; i < 255; i++) {
-            try { builder.removeCapability(i); } catch (IllegalArgumentException e) {}
-        }
-        NetworkRequest request = builder.build();
         mCallback = new DevToolsNetworkCallback();
-        mCm.registerNetworkCallback(request, mCallback);
+        mCm.registerNetworkCallback(mEmptyRequest, mCallback);
     }
 
     @Override
     public void onDestroy() {
         super.onDestroy();
+        mCellNetwork.release();
+        mMmsNetwork.release();
         mCm.unregisterNetworkCallback(mCallback);
+        mCallback = null;
         unregisterReceiver(mReceiver);
     }
 
@@ -410,13 +461,11 @@
                 case R.id.stopTdls:
                     onStopTdls();
                     break;
-                case R.id.start_mms:
-                    mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
-                            Phone.FEATURE_ENABLE_MMS);
+                case R.id.request_mms:
+                    mMmsNetwork.request();
                     break;
-                case R.id.stop_mms:
-                    mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
-                            Phone.FEATURE_ENABLE_MMS);
+                case R.id.release_mms:
+                    mMmsNetwork.release();
                     break;
                 case R.id.default_socket:
                     onDefaultSocket();
@@ -448,13 +497,11 @@
                 case R.id.crash:
                     onCrash();
                     break;
-                case R.id.start_hipri:
-                    mCm.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
-                            Phone.FEATURE_ENABLE_HIPRI);
+                case R.id.request_cell:
+                    mCellNetwork.request();
                     break;
-                case R.id.stop_hipri:
-                    mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
-                            Phone.FEATURE_ENABLE_HIPRI);
+                case R.id.release_cell:
+                    mCellNetwork.release();
                     break;
                 case R.id.link_stats:
                     onLinkStats();
diff --git a/build/sdk-windows-x86.atree b/build/sdk-windows-x86.atree
index cbde057..9856f98 100644
--- a/build/sdk-windows-x86.atree
+++ b/build/sdk-windows-x86.atree
@@ -78,19 +78,22 @@
 rm build-tools/${PLATFORM_NAME}/llvm-rs-cc
 bin/llvm-rs-cc.exe                      strip build-tools/${PLATFORM_NAME}/llvm-rs-cc.exe
 
+# libc++.so not needed on Windows.
+rm build-tools/${PLATFORM_NAME}/lib/libc++.so
+
 rm build-tools/${PLATFORM_NAME}/lib/libLLVM.so
-lib/libLLVM.dll                         strip build-tools/${PLATFORM_NAME}/lib/libLLVM.dll
+lib/libLLVM.dll                         strip build-tools/${PLATFORM_NAME}/libLLVM.dll
 
 rm build-tools/${PLATFORM_NAME}/lib/libclang.so
-lib/libclang.dll                        strip build-tools/${PLATFORM_NAME}/lib/libclang.dll
+lib/libclang.dll                        strip build-tools/${PLATFORM_NAME}/libclang.dll
 
 #bcc not yet compiled on windows
 
 rm build-tools/${PLATFORM_NAME}/lib/libbcc.so
-lib/libbcc.dll                          strip build-tools/${PLATFORM_NAME}/lib/libbcc.dll
+lib/libbcc.dll                          strip build-tools/${PLATFORM_NAME}/libbcc.dll
 
 rm build-tools/${PLATFORM_NAME}/lib/libbcinfo.so
-lib/libbcinfo.dll                       strip build-tools/${PLATFORM_NAME}/lib/libbcinfo.dll
+lib/libbcinfo.dll                       strip build-tools/${PLATFORM_NAME}/libbcinfo.dll
 
 rm build-tools/${PLATFORM_NAME}/bcc_compat
 bin/bcc_compat.exe                      strip build-tools/${PLATFORM_NAME}/bcc_compat.exe
diff --git a/sdk/build_tools_source.prop_template b/sdk/build_tools_source.prop_template
index b83af7f..c9bfc2f 100644
--- a/sdk/build_tools_source.prop_template
+++ b/sdk/build_tools_source.prop_template
@@ -1,3 +1,3 @@
 Pkg.UserSrc=false
-Pkg.Revision=${PLATFORM_SDK_VERSION}.0.1
+Pkg.Revision=${PLATFORM_SDK_VERSION}.0.2
 
diff --git a/sys-img/images_arm64-v8a_source.prop_template b/sys-img/images_arm64-v8a_source.prop_template
index 0fa83e9..7c31def 100644
--- a/sys-img/images_arm64-v8a_source.prop_template
+++ b/sys-img/images_arm64-v8a_source.prop_template
@@ -1,6 +1,6 @@
 Pkg.Desc=Android SDK Platform ${PLATFORM_VERSION}
 Pkg.UserSrc=false
-Pkg.Revision=3
+Pkg.Revision=4
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=${TARGET_CPU_ABI}
diff --git a/sys-img/images_armeabi-v7a_source.prop_template b/sys-img/images_armeabi-v7a_source.prop_template
index 9def03d..36fd33e 100644
--- a/sys-img/images_armeabi-v7a_source.prop_template
+++ b/sys-img/images_armeabi-v7a_source.prop_template
@@ -1,6 +1,6 @@
 Pkg.Desc=Android SDK Platform ${PLATFORM_VERSION}
 Pkg.UserSrc=false
-Pkg.Revision=3
+Pkg.Revision=4
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=armeabi-v7a
diff --git a/sys-img/images_armeabi_source.prop_template b/sys-img/images_armeabi_source.prop_template
index 98281d2..fec8836 100644
--- a/sys-img/images_armeabi_source.prop_template
+++ b/sys-img/images_armeabi_source.prop_template
@@ -1,6 +1,6 @@
 Pkg.Desc=Android SDK Platform ${PLATFORM_VERSION}
 Pkg.UserSrc=false
-Pkg.Revision=3
+Pkg.Revision=4
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=armeabi
diff --git a/sys-img/images_mips64_source.prop_template b/sys-img/images_mips64_source.prop_template
index cd0f010..d457ccc 100644
--- a/sys-img/images_mips64_source.prop_template
+++ b/sys-img/images_mips64_source.prop_template
@@ -1,6 +1,6 @@
 Pkg.Desc=Android SDK Platform ${PLATFORM_VERSION}
 Pkg.UserSrc=false
-Pkg.Revision=3
+Pkg.Revision=4
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=mips64
diff --git a/sys-img/images_mips_source.prop_template b/sys-img/images_mips_source.prop_template
index 09389d0..1b03048 100644
--- a/sys-img/images_mips_source.prop_template
+++ b/sys-img/images_mips_source.prop_template
@@ -1,6 +1,6 @@
 Pkg.Desc=Android SDK Platform ${PLATFORM_VERSION}
 Pkg.UserSrc=false
-Pkg.Revision=3
+Pkg.Revision=4
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=mips
diff --git a/sys-img/images_x86_64_source.prop_template b/sys-img/images_x86_64_source.prop_template
index 0fa83e9..7c31def 100644
--- a/sys-img/images_x86_64_source.prop_template
+++ b/sys-img/images_x86_64_source.prop_template
@@ -1,6 +1,6 @@
 Pkg.Desc=Android SDK Platform ${PLATFORM_VERSION}
 Pkg.UserSrc=false
-Pkg.Revision=3
+Pkg.Revision=4
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=${TARGET_CPU_ABI}
diff --git a/sys-img/images_x86_source.prop_template b/sys-img/images_x86_source.prop_template
index 0fa83e9..7c31def 100644
--- a/sys-img/images_x86_source.prop_template
+++ b/sys-img/images_x86_source.prop_template
@@ -1,6 +1,6 @@
 Pkg.Desc=Android SDK Platform ${PLATFORM_VERSION}
 Pkg.UserSrc=false
-Pkg.Revision=3
+Pkg.Revision=4
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=${TARGET_CPU_ABI}