package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import org.;
import org.;
import org.;
import org.;
import org.;
import ;
import .;
import .;
import .;
import ;
import ;
import ;
import ;
import ;
import ;
final class VendorSettings {
private static final String TAG_ROOT = "packages";
private static final String TAG_PACKAGE = "package";
static final String ATTR_PACKAGE_NAME = "name";
static final String ATTR_INSTALL_STATUS = "installStatus";
static final String VAL_INSTALLED = "installed";
static final String VAL_UNINSTALLED = "uninstalled";
private final File mSystemDir;
private final File mVendorSettingsFilename;
private final File mVendorBackupSettingsFilename;
final HashMap<String, VendorPackageSettings> mVendorPackages =
new HashMap<String, VendorPackageSettings>();
VendorSettings() {
this(());
}
VendorSettings(File dataDir) {
mSystemDir = new File(dataDir, "system");;
();
((),
FileUtils.S_IRWXU|FileUtils.S_IRWXG
|FileUtils.S_IROTH|FileUtils.S_IXOTH,
-1, -1);
mVendorSettingsFilename = new File(mSystemDir, "");
mVendorBackupSettingsFilename = new File(mSystemDir, "");
}
void insertPackage(String packageName, boolean installStatus) {
VendorPackageSettings vps = (packageName);
if (vps != null) {
(installStatus);
} else {
vps = new VendorPackageSettings(packageName, installStatus);
(packageName, vps);
}
}
void setPackageStatus(String packageName, boolean installStatus) {
VendorPackageSettings vps = (packageName);
if (vps == null) {
return;
} else {
(installStatus);
}
}
void removePackage(String packageName) {
if ((packageName) != null) {
(packageName);
}
}
void readLPw() {
FileInputStream str = null;
DocumentBuilderFactory docBuilderFactory = null;
DocumentBuilder docBuilder = null;
Document doc = null;
if (()) {
try {
str = new FileInputStream(mVendorBackupSettingsFilename);
if (()) {
(, "Cleaning up settings file");
mVendorSettingsFilename.delete();
}
} catch ( e) {
}
}
try {
if (str == null) {
if (!()) {
return;
}
str = new FileInputStream(mVendorSettingsFilename);
}
docBuilderFactory = ();
docBuilder = ();
doc = (str);
Element root = ();
NodeList nodeList = (TAG_PACKAGE);
Node node = null;
NamedNodeMap nodeMap = null;
String packageName = null;
String installStatus = null;
for (int i = 0; i < (); i++) {
node = (i);
if (().equals(TAG_PACKAGE)) {
nodeMap = ();
packageName = (ATTR_PACKAGE_NAME).getTextContent();
installStatus = (ATTR_INSTALL_STATUS).getTextContent();
(packageName,
new VendorPackageSettings(packageName, (VAL_INSTALLED)));
}
}
} catch ( e) {
();
} catch (ParserConfigurationException e) {
();
} catch (SAXException e) {
();
}
}
void writeLPr() {
if (()) {
if (!()) {
if (!(mVendorBackupSettingsFilename)) {
(, "Unable to backup package manager vendor settings, "
+ " current changes will be lost at reboot");
return;
}
} else {
mVendorSettingsFilename.delete();
(, "Preserving older vendor settings backup");
}
}
try {
FileOutputStream fstr = new FileOutputStream(mVendorSettingsFilename);
XmlSerializer serializer = new FastXmlSerializer();
BufferedOutputStream str = new BufferedOutputStream(fstr);
(str, "utf-8");
(null, true);
(null, TAG_ROOT);
for (VendorPackageSettings ps : ()) {
(null, TAG_PACKAGE);
(null, ATTR_PACKAGE_NAME, ());
(null, ATTR_INSTALL_STATUS,
() ? VAL_INSTALLED : VAL_UNINSTALLED);
(null, TAG_PACKAGE);
}
(null, TAG_ROOT);
();
();
(fstr);
();
mVendorBackupSettingsFilename.delete();
((),
FileUtils.S_IRUSR|FileUtils.S_IWUSR
|FileUtils.S_IRGRP|FileUtils.S_IWGRP,
-1, -1);
} catch (IllegalArgumentException e) {
();
} catch (IllegalStateException e) {
();
} catch (IOException e) {
();
}
}
}