Source:
public void testLibraryVersion3MergeInPreviewApp ( ) throws java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { java.lang.String main = "" + ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <application android:label=\"@string/lib_name\" />\n" ) + " <uses-sdk android:targetSdkVersion=\"XYZ\"/>\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String library = "" + ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:acme=\"http://acme.org/schemas\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <activity android:name=\"activityOne\" />\n" ) + " <uses-sdk android:targetSdkVersion=\"3\"/>\n" ) + "\n" ) + "</manifest>" ) ; com.android.manifmerger.XmlDocument mainDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "main" ) , main ) ; com.android.manifmerger.XmlDocument libraryDocument = com.android.manifmerger.TestUtils.xmlLibraryFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "library" ) , library ) ; com.android.manifmerger.MergingReport.Builder mergingReportBuilder = new com.android.manifmerger.MergingReport.Builder ( mLogger ) ; com.google.common.base.Optional < com.android.manifmerger.XmlDocument > mergedDocument = mainDocument.merge ( libraryDocument , mergingReportBuilder ) ; assertTrue ( mergedDocument.isPresent ( ) ) ; com.android.manifmerger.XmlDocument xmlDocument = mergedDocument.get ( ) ; assertTrue ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.WRITE_EXTERNAL_STORAGE" ) . isPresent ( ) ) ; assertTrue ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.READ_EXTERNAL_STORAGE" ) . isPresent ( ) ) ; assertTrue ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.READ_PHONE_STATE" ) . isPresent ( ) ) ; assertFalse ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.READ_CALL_LOG" ) . isPresent ( ) ) ; assertFalse ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.WRITE_CALL_LOG" ) . isPresent ( ) ) ; com.android.manifmerger.Actions actions = mergingReportBuilder.getActionRecorder ( ) . build ( ) ; com.android.manifmerger.XmlElement xmlElement = xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.WRITE_EXTERNAL_STORAGE" ) . get ( ) ; com.google.common.collect.ImmutableList < com.android.manifmerger.Actions.NodeRecord > nodeRecords = actions.getNodeRecords ( XmlNode.NodeKey.fromXml ( xmlElement.getXml ( ) ) ) ; assertEquals ( 1 , nodeRecords.size ( ) ) ; assertEquals ( nodeRecords.iterator ( ) . next ( ) . mReason , "targetSdkVersion < 4" ) ; }

Target:
public void testLibraryVersion3MergeInPreviewApp ( ) throws java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { java.lang.String main = "" + ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <application android:label=\"@string/lib_name\" />\n" ) + " <uses-sdk android:targetSdkVersion=\"XYZ\"/>\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String library = "" + ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:acme=\"http://acme.org/schemas\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <activity android:name=\"activityOne\" />\n" ) + " <uses-sdk android:targetSdkVersion=\"3\"/>\n" ) + "\n" ) + "</manifest>" ) ; com.android.manifmerger.XmlDocument mainDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "main" ) , main ) ; com.android.manifmerger.XmlDocument libraryDocument = com.android.manifmerger.TestUtils.xmlLibraryFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "library" ) , library ) ; com.android.manifmerger.MergingReport.Builder mergingReportBuilder = new com.android.manifmerger.MergingReport.Builder ( mLogger ) ; com.google.common.base.Optional < com.android.manifmerger.XmlDocument > mergedDocument = mainDocument.merge ( libraryDocument , mergingReportBuilder ) ; assertTrue ( mergedDocument.isPresent ( ) ) ; com.android.manifmerger.XmlDocument xmlDocument = mergedDocument.get ( ) ; assertTrue ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.WRITE_EXTERNAL_STORAGE" ) . isPresent ( ) ) ; assertTrue ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.READ_EXTERNAL_STORAGE" ) . isPresent ( ) ) ; assertTrue ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.READ_PHONE_STATE" ) . isPresent ( ) ) ; assertFalse ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.READ_CALL_LOG" ) . isPresent ( ) ) ; assertFalse ( xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.WRITE_CALL_LOG" ) . isPresent ( ) ) ; com.android.manifmerger.Actions actions = mergingReportBuilder.getActionRecorder ( ) . build ( ) ; com.android.manifmerger.XmlElement xmlElement = xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.USES_PERMISSION , "android.permission.WRITE_EXTERNAL_STORAGE" ) . get ( ) ; com.google.common.collect.ImmutableList < com.android.manifmerger.Actions.NodeRecord > nodeRecords = actions.getNodeRecords ( XmlNode.NodeKey.fromXml ( xmlElement.getXml ( ) ) ) ; assertEquals ( 1 , nodeRecords.size ( ) ) ; assertEquals ( nodeRecords.iterator ( ) . next ( ) . mReason , "com.example.lib3 has a targetSdkVersion < 4" ) ; }