public void writeValue(final boolean isChecked) { if (!isSupported()) { return; } if (mPaths != null && mMultiFile) { final int length = mPaths.length; for (int i = 0; i < length; i++) { Utils.writeValue(mPaths[i], (isChecked ? mValueChecked : mValueNotChecked)); if (mStartup) { BootupConfig.setBootup( new BootupItem( mCategory, getKey() + String.valueOf(i), mPaths[i], (isChecked ? mValueChecked : mValueNotChecked), true)); } } } else { Utils.writeValue(mPath, (isChecked ? mValueChecked : mValueNotChecked)); if (mStartup) { BootupConfig.setBootup( new BootupItem( mCategory, getKey(), mPath, (isChecked ? mValueChecked : mValueNotChecked), true)); } } postDelayed( new Runnable() { @Override public void run() { initValue(); } }, 200); }
public static String restore(BootupConfig config) { final boolean hasVdd = Utils.fileExists(VoltageUtils.VDD_TABLE_FILE); final boolean hasUv = Utils.fileExists(VoltageUtils.UV_TABLE_FILE); if (!hasVdd && !hasUv) { return ""; } final ArrayList<BootupItem> bootupItems = config.getItemsByCategory(BootupConfig.CATEGORY_VOLTAGE); if (bootupItems.size() == 0) { return ""; } final BootupItem voltageBootupItem = bootupItems.get(0); if (voltageBootupItem == null || !voltageBootupItem.enabled) { return ""; } final StringBuilder restore = new StringBuilder(); if (hasVdd) { final String value = ExtraConfig.get().vdd; Logger.v(VoltageFragment.class, "VDD Table: " + value); if (!TextUtils.isEmpty(value)) { final String[] values = value.split("XXX"); for (final String s : values) { restore.append(Utils.getWriteCommand(VoltageUtils.VDD_TABLE_FILE, s)); } } } else { final String value = ExtraConfig.get().uv; Logger.v(VoltageFragment.class, "UV Table: " + value); if (!TextUtils.isEmpty(value)) { restore.append(Utils.getWriteCommand(VoltageUtils.UV_TABLE_FILE, value)); } } return restore.toString(); }