Merge in history after reset to stage-aosp-mnc-mr1-release@04d23e6526745822df2e62d78160fdcb1bd0a2e6
diff --git a/tests/tests/graphics/assets/bombfont.ttf b/tests/tests/graphics/assets/bombfont.ttf
deleted file mode 100644
index 66a89f8..0000000
--- a/tests/tests/graphics/assets/bombfont.ttf
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/assets/bombfont.ttx b/tests/tests/graphics/assets/bombfont.ttx
deleted file mode 100644
index bf544da..0000000
--- a/tests/tests/graphics/assets/bombfont.ttx
+++ /dev/null
@@ -1,241 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0">
-
-  <GlyphOrder>
-    <!-- The 'id' attribute is only for humans; it is ignored when parsed. -->
-    <GlyphID id="0" name=".notdef"/>
-    <GlyphID id="1" name="a"/>
-    <GlyphID id="2" name="b"/>
-    <GlyphID id="3" name="c"/>
-    <GlyphID id="4" name="d"/>
-    <GlyphID id="5" name="e"/>
-    <GlyphID id="6" name="BombEmoji"/>
-  </GlyphOrder>
-
-  <head>
-    <!-- Most of this table will be recalculated by the compiler -->
-    <tableVersion value="1.0"/>
-    <fontRevision value="1.0"/>
-    <checkSumAdjustment value="0xaf28220f"/>
-    <magicNumber value="0x5f0f3cf5"/>
-    <flags value="00000000 00000011"/>
-    <unitsPerEm value="1000"/>
-    <created value="Wed Sep  9 08:01:17 2015"/>
-    <modified value="Tue Dec  8 03:58:55 2015"/>
-    <xMin value="0"/>
-    <yMin value="0"/>
-    <xMax value="0"/>
-    <yMax value="0"/>
-    <macStyle value="00000000 00000000"/>
-    <lowestRecPPEM value="7"/>
-    <fontDirectionHint value="2"/>
-    <indexToLocFormat value="0"/>
-    <glyphDataFormat value="0"/>
-  </head>
-
-  <hhea>
-    <tableVersion value="1.0"/>
-    <ascent value="1000"/>
-    <descent value="-200"/>
-    <lineGap value="0"/>
-    <advanceWidthMax value="500"/>
-    <minLeftSideBearing value="0"/>
-    <minRightSideBearing value="0"/>
-    <xMaxExtent value="0"/>
-    <caretSlopeRise value="1"/>
-    <caretSlopeRun value="0"/>
-    <caretOffset value="0"/>
-    <reserved0 value="0"/>
-    <reserved1 value="0"/>
-    <reserved2 value="0"/>
-    <reserved3 value="0"/>
-    <metricDataFormat value="0"/>
-    <numberOfHMetrics value="1"/>
-  </hhea>
-
-  <maxp>
-    <!-- Most of this table will be recalculated by the compiler -->
-    <tableVersion value="0x10000"/>
-    <numGlyphs value="7"/>
-    <maxPoints value="0"/>
-    <maxContours value="0"/>
-    <maxCompositePoints value="0"/>
-    <maxCompositeContours value="0"/>
-    <maxZones value="2"/>
-    <maxTwilightPoints value="12"/>
-    <maxStorage value="28"/>
-    <maxFunctionDefs value="119"/>
-    <maxInstructionDefs value="0"/>
-    <maxStackElements value="61"/>
-    <maxSizeOfInstructions value="2967"/>
-    <maxComponentElements value="0"/>
-    <maxComponentDepth value="0"/>
-  </maxp>
-
-  <OS_2>
-    <!-- The fields 'usFirstCharIndex' and 'usLastCharIndex'
-         will be recalculated by the compiler -->
-    <version value="3"/>
-    <xAvgCharWidth value="594"/>
-    <usWeightClass value="400"/>
-    <usWidthClass value="5"/>
-    <fsType value="00000000 00001000"/>
-    <ySubscriptXSize value="650"/>
-    <ySubscriptYSize value="600"/>
-    <ySubscriptXOffset value="0"/>
-    <ySubscriptYOffset value="75"/>
-    <ySuperscriptXSize value="650"/>
-    <ySuperscriptYSize value="600"/>
-    <ySuperscriptXOffset value="0"/>
-    <ySuperscriptYOffset value="350"/>
-    <yStrikeoutSize value="50"/>
-    <yStrikeoutPosition value="300"/>
-    <sFamilyClass value="0"/>
-    <panose>
-      <bFamilyType value="0"/>
-      <bSerifStyle value="0"/>
-      <bWeight value="5"/>
-      <bProportion value="0"/>
-      <bContrast value="0"/>
-      <bStrokeVariation value="0"/>
-      <bArmStyle value="0"/>
-      <bLetterForm value="0"/>
-      <bMidline value="0"/>
-      <bXHeight value="0"/>
-    </panose>
-    <ulUnicodeRange1 value="00000000 00000000 00000000 00000001"/>
-    <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/>
-    <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/>
-    <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
-    <achVendID value="UKWN"/>
-    <fsSelection value="00000000 01000000"/>
-    <usFirstCharIndex value="97"/>
-    <usLastCharIndex value="65535"/>
-    <sTypoAscender value="800"/>
-    <sTypoDescender value="-200"/>
-    <sTypoLineGap value="200"/>
-    <usWinAscent value="1000"/>
-    <usWinDescent value="200"/>
-    <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/>
-    <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/>
-    <sxHeight value="500"/>
-    <sCapHeight value="700"/>
-    <usDefaultChar value="0"/>
-    <usBreakChar value="32"/>
-    <usMaxContext value="0"/>
-  </OS_2>
-
-  <hmtx>
-    <mtx name=".notdef" width="500" lsb="93"/>
-    <mtx name="BombEmoji" width="500" lsb="93"/>
-    <mtx name="a" width="500" lsb="93"/>
-    <mtx name="b" width="500" lsb="93"/>
-    <mtx name="c" width="500" lsb="93"/>
-    <mtx name="d" width="500" lsb="93"/>
-    <mtx name="e" width="500" lsb="93"/>
-  </hmtx>
-
-  <cmap ERROR="decompilation error" raw="True">
-    <!-- An error occurred during the decompilation of this table -->
-    <hexdata>
-      00000002 00030001 00000014 00030001
-      00000034 00040020 00000004 00040001
-      00000065 ffff0000 0061ffff ffa00001
-      00000000 000c0000 00000028 00000000
-      80000002 00000061 00000065 00000001
-      0001f4a3 0001f4a3 00000006 
-    </hexdata>
-  </cmap>
-
-  <loca>
-    <!-- The 'loca' table will be calculated by the compiler -->
-  </loca>
-
-  <glyf>
-
-    <!-- The xMin, yMin, xMax and yMax values
-         will be recalculated by the compiler. -->
-
-    <TTGlyph name=".notdef"/><!-- contains no outline data -->
-
-    <TTGlyph name="BombEmoji"/><!-- contains no outline data -->
-
-    <TTGlyph name="a"/><!-- contains no outline data -->
-
-    <TTGlyph name="b"/><!-- contains no outline data -->
-
-    <TTGlyph name="c"/><!-- contains no outline data -->
-
-    <TTGlyph name="d"/><!-- contains no outline data -->
-
-    <TTGlyph name="e"/><!-- contains no outline data -->
-
-  </glyf>
-
-  <name>
-    <namerecord nameID="1" platformID="1" platEncID="0" langID="0x0" unicode="True">
-      SampleFont Test
-    </namerecord>
-    <namerecord nameID="2" platformID="1" platEncID="0" langID="0x0" unicode="True">
-      Regular
-    </namerecord>
-    <namerecord nameID="4" platformID="1" platEncID="0" langID="0x0" unicode="True">
-      SampleFont Test
-    </namerecord>
-    <namerecord nameID="6" platformID="1" platEncID="0" langID="0x0" unicode="True">
-      SampleFontTest-Regular
-    </namerecord>
-    <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
-      SampleFont Test
-    </namerecord>
-    <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409">
-      Regular
-    </namerecord>
-    <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409">
-      SampleFont Test
-    </namerecord>
-    <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409">
-      SampleFontTest-Regular
-    </namerecord>
-  </name>
-
-  <post>
-    <formatType value="2.0"/>
-    <italicAngle value="0.0"/>
-    <underlinePosition value="-166"/>
-    <underlineThickness value="20"/>
-    <isFixedPitch value="0"/>
-    <minMemType42 value="0"/>
-    <maxMemType42 value="0"/>
-    <minMemType1 value="0"/>
-    <maxMemType1 value="0"/>
-    <psNames>
-      <!-- This file uses unique glyph names based on the information
-           found in the 'post' table. Since these names might not be unique,
-           we have to invent artificial names in case of clashes. In order to
-           be able to retain the original information, we need a name to
-           ps name mapping for those cases where they differ. That's what
-           you see below.
-            -->
-    </psNames>
-    <extraNames>
-      <!-- following are the name that are not taken from the standard Mac glyph order -->
-      <psName name="BombEmoji"/>
-    </extraNames>
-  </post>
-
-</ttFont>
diff --git a/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java b/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
index 7b0277c..5932e64 100644
--- a/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
@@ -17,7 +17,6 @@
 package android.graphics.cts;
 
 
-import android.graphics.Paint;
 import android.graphics.Typeface;
 import android.content.res.AssetFileDescriptor;
 import android.content.res.AssetManager;
@@ -181,15 +180,4 @@
         fOutput.close();
         return (file.getPath());
     }
-
-    public void testInvalidCmapFont() {
-        Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "bombfont.ttf");
-        assertNotNull(typeface);
-        Paint p = new Paint();
-        final String testString = "abcde";
-        float widthDefaultTypeface = p.measureText(testString);
-        p.setTypeface(typeface);
-        float widthCustomTypeface = p.measureText(testString);
-        assertEquals(widthDefaultTypeface, widthCustomTypeface, 0.01f);
-    }
 }
diff --git a/tests/tests/security/AndroidManifest.xml b/tests/tests/security/AndroidManifest.xml
index 3039f81..d8d8dfa 100644
--- a/tests/tests/security/AndroidManifest.xml
+++ b/tests/tests/security/AndroidManifest.xml
@@ -23,7 +23,6 @@
     <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 
     <application>
         <uses-library android:name="android.test.runner" />
diff --git a/tests/tests/security/res/raw/drm_uaf.dm b/tests/tests/security/res/raw/drm_uaf.dm
deleted file mode 100644
index 50f42bc..0000000
--- a/tests/tests/security/res/raw/drm_uaf.dm
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/src/android/security/cts/MediaServerCrashTest.java b/tests/tests/security/src/android/security/cts/MediaServerCrashTest.java
index 9dff6dd..4dc6783 100644
--- a/tests/tests/security/src/android/security/cts/MediaServerCrashTest.java
+++ b/tests/tests/security/src/android/security/cts/MediaServerCrashTest.java
@@ -17,259 +17,70 @@
 package android.security.cts;
 
 import android.content.res.AssetFileDescriptor;
-import android.drm.DrmConvertedStatus;
-import android.drm.DrmManagerClient;
 import android.media.MediaPlayer;
 import android.os.ConditionVariable;
-import android.os.Environment;
-import android.os.ParcelFileDescriptor;
 import android.test.AndroidTestCase;
 import android.util.Log;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
 import com.android.cts.security.R;
 
 public class MediaServerCrashTest extends AndroidTestCase {
     private static final String TAG = "MediaServerCrashTest";
 
-    private static final String MIMETYPE_DRM_MESSAGE = "application/vnd.oma.drm.message";
+    public void testInvalidMidiNullPointerAccess() throws Exception {
+        testIfMediaServerDied(R.raw.midi_crash);
+    }
 
-    private String mFlFilePath;
+    private void testIfMediaServerDied(int res) throws Exception {
+        final MediaPlayer mediaPlayer = new MediaPlayer();
+        final ConditionVariable onPrepareCalled = new ConditionVariable();
+        final ConditionVariable onCompletionCalled = new ConditionVariable();
 
-    private final MediaPlayer mMediaPlayer = new MediaPlayer();
-    private final ConditionVariable mOnPrepareCalled = new ConditionVariable();
-    private final ConditionVariable mOnCompletionCalled = new ConditionVariable();
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mFlFilePath = new File(Environment.getExternalStorageDirectory(),
-                "temp.fl").getAbsolutePath();
-
-        mOnPrepareCalled.close();
-        mOnCompletionCalled.close();
-        mMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
+        onPrepareCalled.close();
+        onCompletionCalled.close();
+        mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
             @Override
             public boolean onError(MediaPlayer mp, int what, int extra) {
-                assertTrue(mp == mMediaPlayer);
+                assertTrue(mp == mediaPlayer);
                 assertTrue("mediaserver process died", what != MediaPlayer.MEDIA_ERROR_SERVER_DIED);
                 Log.w(TAG, "onError " + what);
                 return false;
             }
         });
 
-        mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
+        mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
             @Override
             public void onPrepared(MediaPlayer mp) {
-                assertTrue(mp == mMediaPlayer);
-                mOnPrepareCalled.open();
+                assertTrue(mp == mediaPlayer);
+                onPrepareCalled.open();
             }
         });
 
-        mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
+        mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
             @Override
             public void onCompletion(MediaPlayer mp) {
-                assertTrue(mp == mMediaPlayer);
-                mOnCompletionCalled.open();
+                assertTrue(mp == mediaPlayer);
+                onCompletionCalled.open();
             }
         });
-    }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        File flFile = new File(mFlFilePath);
-        if (flFile.exists()) {
-            flFile.delete();
-        }
-    }
-
-    public void testInvalidMidiNullPointerAccess() throws Exception {
-        testIfMediaServerDied(R.raw.midi_crash);
-    }
-
-    private void testIfMediaServerDied(int res) throws Exception {
         AssetFileDescriptor afd = getContext().getResources().openRawResourceFd(res);
-        mMediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
+        mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
         afd.close();
         try {
-            mMediaPlayer.prepareAsync();
-            if (!mOnPrepareCalled.block(5000)) {
+            mediaPlayer.prepareAsync();
+            if (!onPrepareCalled.block(5000)) {
                 Log.w(TAG, "testIfMediaServerDied: Timed out waiting for prepare");
                 return;
             }
-            mMediaPlayer.start();
-            if (!mOnCompletionCalled.block(5000)) {
+            mediaPlayer.start();
+            if (!onCompletionCalled.block(5000)) {
                 Log.w(TAG, "testIfMediaServerDied: Timed out waiting for Error/Completion");
             }
         } catch (Exception e) {
             Log.w(TAG, "playback failed", e);
         } finally {
-            mMediaPlayer.release();
+            mediaPlayer.release();
         }
     }
-
-    public void testDrmManagerClientReset() throws Exception {
-        checkIfMediaServerDiedForDrm(R.raw.drm_uaf);
-    }
-
-    private void checkIfMediaServerDiedForDrm(int res) throws Exception {
-        if (!convertDmToFl(res, mFlFilePath)) {
-            fail("Can not convert dm to fl");
-        }
-        Log.d(TAG, "intermediate fl file is " + mFlFilePath);
-
-        ParcelFileDescriptor flFd = null;
-        try {
-            flFd = ParcelFileDescriptor.open(new File(mFlFilePath),
-                    ParcelFileDescriptor.MODE_READ_ONLY);
-        } catch (FileNotFoundException e) {
-            fail("Could not find file: " + mFlFilePath +  e);
-        }
-
-        mMediaPlayer.setDataSource(flFd.getFileDescriptor(), 0, flFd.getStatSize());
-        flFd.close();
-        try {
-            mMediaPlayer.prepare();
-        } catch (Exception e) {
-            Log.d(TAG, "Prepare failed", e);
-        }
-
-        try {
-            mMediaPlayer.reset();
-            if (!mOnCompletionCalled.block(5000)) {
-                Log.w(TAG, "checkIfMediaServerDiedForDrm: Timed out waiting for Error/Completion");
-            }
-        } catch (Exception e) {
-            fail("reset failed" + e);
-        } finally {
-            mMediaPlayer.release();
-        }
-    }
-
-    private boolean convertDmToFl(int res, String flFilePath) throws Exception {
-        AssetFileDescriptor afd = getContext().getResources().openRawResourceFd(res);
-        FileInputStream inputStream = afd.createInputStream();
-        int inputLength = (int)afd.getLength();
-        byte[] fileData = new byte[inputLength];
-        int readSize = inputStream.read(fileData, 0, inputLength);
-        assertEquals("can not pull in all data", readSize, inputLength);
-        inputStream.close();
-        afd.close();
-
-        FileOutputStream flStream = new FileOutputStream(new File(flFilePath));
-
-        DrmManagerClient drmClient = null;
-        try {
-            drmClient = new DrmManagerClient(mContext);
-        } catch (IllegalArgumentException e) {
-            Log.w(TAG, "DrmManagerClient instance could not be created, context is Illegal.");
-            return false;
-        } catch (IllegalStateException e) {
-            Log.w(TAG, "DrmManagerClient didn't initialize properly.");
-            return false;
-        }
-
-        if (drmClient == null) {
-            Log.w(TAG, "Failed to create DrmManagerClient.");
-            return false;
-        }
-
-        int convertSessionId = -1;
-        try {
-            convertSessionId = drmClient.openConvertSession(MIMETYPE_DRM_MESSAGE);
-        } catch (IllegalArgumentException e) {
-            Log.w(TAG, "Conversion of Mimetype: " + MIMETYPE_DRM_MESSAGE
-                    + " is not supported.", e);
-            return false;
-        } catch (IllegalStateException e) {
-            Log.w(TAG, "Could not access Open DrmFramework.", e);
-            return false;
-        }
-
-        if (convertSessionId < 0) {
-            Log.w(TAG, "Failed to open session.");
-            return false;
-        }
-
-        DrmConvertedStatus convertedStatus = null;
-        try {
-            convertedStatus = drmClient.convertData(convertSessionId, fileData);
-        } catch (IllegalArgumentException e) {
-            Log.w(TAG, "Buffer with data to convert is illegal. Convertsession: "
-                    + convertSessionId, e);
-            return false;
-        } catch (IllegalStateException e) {
-            Log.w(TAG, "Could not convert data. Convertsession: " + convertSessionId, e);
-            return false;
-        }
-
-        if (convertedStatus == null ||
-                convertedStatus.statusCode != DrmConvertedStatus.STATUS_OK ||
-                convertedStatus.convertedData == null) {
-            Log.w(TAG, "Error in converting data. Convertsession: " + convertSessionId);
-            try {
-                drmClient.closeConvertSession(convertSessionId);
-            } catch (IllegalStateException e) {
-                Log.w(TAG, "Could not close session. Convertsession: " +
-                       convertSessionId, e);
-            }
-            return false;
-        }
-
-        flStream.write(convertedStatus.convertedData, 0, convertedStatus.convertedData.length);
-        flStream.close();
-
-        try {
-            convertedStatus = drmClient.closeConvertSession(convertSessionId);
-        } catch (IllegalStateException e) {
-            Log.w(TAG, "Could not close convertsession. Convertsession: " +
-                    convertSessionId, e);
-            return false;
-        }
-
-        if (convertedStatus == null ||
-                convertedStatus.statusCode != DrmConvertedStatus.STATUS_OK ||
-                convertedStatus.convertedData == null) {
-            Log.w(TAG, "Error in closing session. Convertsession: " + convertSessionId);
-            return false;
-        }
-
-        RandomAccessFile flRandomAccessFile = null;
-        try {
-            flRandomAccessFile = new RandomAccessFile(flFilePath, "rw");
-            flRandomAccessFile.seek(convertedStatus.offset);
-            flRandomAccessFile.write(convertedStatus.convertedData);
-        } catch (FileNotFoundException e) {
-            Log.w(TAG, "File: " + flFilePath + " could not be found.", e);
-            return false;
-        } catch (IOException e) {
-            Log.w(TAG, "Could not access File: " + flFilePath + " .", e);
-            return false;
-        } catch (IllegalArgumentException e) {
-            Log.w(TAG, "Could not open file in mode: rw", e);
-            return false;
-        } catch (SecurityException e) {
-            Log.w(TAG, "Access to File: " + flFilePath +
-                    " was denied denied by SecurityManager.", e);
-            return false;
-        } finally {
-            if (flRandomAccessFile != null) {
-                try {
-                    flRandomAccessFile.close();
-                } catch (IOException e) {
-                    Log.w(TAG, "Failed to close File:" + flFilePath + ".", e);
-                    return false;
-                }
-            }
-        }
-
-        return true;
-    }
 }