@@ -62,7 +62,7 @@ public ResPackage loadMainPkg(ResTable resTable, ExtFile apkFile)
62
62
throws AndrolibException {
63
63
LOGGER .info ("Loading resource table..." );
64
64
ResPackage [] pkgs = getResPackagesFromApk (apkFile , resTable , sKeepBroken );
65
- ResPackage pkg = null ;
65
+ ResPackage pkg ;
66
66
67
67
switch (pkgs .length ) {
68
68
case 1 :
@@ -71,14 +71,11 @@ public ResPackage loadMainPkg(ResTable resTable, ExtFile apkFile)
71
71
case 2 :
72
72
if (pkgs [0 ].getName ().equals ("android" )) {
73
73
LOGGER .warning ("Skipping \" android\" package group" );
74
- pkg = pkgs [1 ];
75
- break ;
76
74
} else if (pkgs [0 ].getName ().equals ("com.htc" )) {
77
75
LOGGER .warning ("Skipping \" htc\" package group" );
78
- pkg = pkgs [1 ];
79
- break ;
80
76
}
81
-
77
+ pkg = pkgs [1 ];
78
+ break ;
82
79
default :
83
80
pkg = selectPkgWithMostResSpecs (pkgs );
84
81
break ;
@@ -128,7 +125,7 @@ public ResPackage loadFrameworkPkg(ResTable resTable, int id, String frameTag)
128
125
}
129
126
130
127
if (pkg .getId () != id ) {
131
- throw new AndrolibException ("Expected pkg of id: " + String . valueOf ( id ) + ", got: " + pkg .getId ());
128
+ throw new AndrolibException ("Expected pkg of id: " + id + ", got: " + pkg .getId ());
132
129
}
133
130
134
131
resTable .addPackage (pkg , false );
@@ -619,7 +616,7 @@ public void aaptPackage(File apkFile, File manifest, File resDir, File rawDir, F
619
616
620
617
String aaptPath = apkOptions .aaptPath ;
621
618
boolean customAapt = !aaptPath .isEmpty ();
622
- List <String > cmd = new ArrayList <String >();
619
+ List <String > cmd = new ArrayList <>();
623
620
624
621
try {
625
622
String aaptCommand = AaptManager .getAaptExecutionCommand (aaptPath , getAaptBinaryFile ());
@@ -705,7 +702,7 @@ public Duo<ResFileDecoder, AXmlResourceParser> getResFileDecoder() {
705
702
axmlParser .setAttrDecoder (new ResAttrDecoder ());
706
703
decoders .setDecoder ("xml" , new XmlPullStreamDecoder (axmlParser , getResXmlSerializer ()));
707
704
708
- return new Duo <ResFileDecoder , AXmlResourceParser >(new ResFileDecoder (decoders ), axmlParser );
705
+ return new Duo <>(new ResFileDecoder (decoders ), axmlParser );
709
706
}
710
707
711
708
public Duo <ResFileDecoder , AXmlResourceParser > getManifestFileDecoder (boolean withResources ) {
@@ -717,7 +714,7 @@ public Duo<ResFileDecoder, AXmlResourceParser> getManifestFileDecoder(boolean wi
717
714
}
718
715
decoders .setDecoder ("xml" , new XmlPullStreamDecoder (axmlParser ,getResXmlSerializer ()));
719
716
720
- return new Duo <ResFileDecoder , AXmlResourceParser >(new ResFileDecoder (decoders ), axmlParser );
717
+ return new Duo <>(new ResFileDecoder (decoders ), axmlParser );
721
718
}
722
719
723
720
public ExtMXSerializer getResXmlSerializer () {
@@ -783,15 +780,10 @@ private ResPackage[] getResPackagesFromApk(ExtFile apkFile,ResTable resTable, bo
783
780
throws AndrolibException {
784
781
try {
785
782
Directory dir = apkFile .getDirectory ();
786
- BufferedInputStream bfi = new BufferedInputStream (dir .getFileInput ("resources.arsc" ));
787
- try {
783
+ try (BufferedInputStream bfi = new BufferedInputStream (dir .getFileInput ("resources.arsc" ))) {
788
784
return ARSCDecoder .decode (bfi , false , keepBroken , resTable ).getPackages ();
789
- } finally {
790
- try {
791
- bfi .close ();
792
- } catch (IOException ignored ) {}
793
785
}
794
- } catch (DirectoryException ex ) {
786
+ } catch (DirectoryException | IOException ex ) {
795
787
throw new AndrolibException ("Could not load resources.arsc from file: " + apkFile , ex );
796
788
}
797
789
}
@@ -808,7 +800,7 @@ public File getFrameworkApk(int id, String frameTag)
808
800
}
809
801
}
810
802
811
- apk = new File (dir , String . valueOf ( id ) + ".apk" );
803
+ apk = new File (dir , id + ".apk" );
812
804
if (apk .exists ()) {
813
805
return apk ;
814
806
}
@@ -888,8 +880,8 @@ public void installFramework(File frameFile, String tag)
888
880
ARSCData arsc = ARSCDecoder .decode (new ByteArrayInputStream (data ), true , true );
889
881
publicizeResources (data , arsc .getFlagsOffsets ());
890
882
891
- File outFile = new File (getFrameworkDir (), String . valueOf ( arsc
892
- .getOnePackage ().getId () )
883
+ File outFile = new File (getFrameworkDir (), arsc
884
+ .getOnePackage ().getId ()
893
885
+ (tag == null ? "" : '-' + tag )
894
886
+ ".apk" );
895
887
0 commit comments