Java Code Examples for com.grarak.kerneladiutor.utils.Utils

The following examples show how to use com.grarak.kerneladiutor.utils.Utils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: kernel_adiutor   Source File: MiscFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
  public void onStop(SeekBarCardView.DSeekBarCard dSeekBarCard, int position) {
      if (dSeekBarCard == mVibrationCard) {
          int max = Misc.getVibrationMax();
          int min = Misc.getVibrationMin();
          float offset = (max - min) / (float) 101;
          Misc.setVibration(Math.round(offset * position) + min, getActivity());

          // Vibrate
          new Thread(new Runnable() {
              @Override
              public void run() {
                  try {
                      Thread.sleep(100);
                      Utils.vibrate(300);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
          }).start();
      }
else if (dSeekBarCard == mLedSetSpeedCard) {
          Misc.setLedSpeed(position, getActivity());
}
  }
 
Example 2
Source Project: KernelAdiutor   Source File: CPUBoost.java    License: GNU General Public License v3.0 6 votes vote down vote up
public List<Integer> getCpuBootInputFreq() {
    CPUFreq cpuFreq = CPUFreq.getInstance();

    List<Integer> list = new ArrayList<>();
    String value = Utils.readFile(CPU_BOOST_INPUT_BOOST_FREQ);
    if (value.contains(":")) {
        for (String line : value.split(" ")) {
            int core = Utils.strToInt(line.split(":")[0]);
            String freq = line.split(":")[1];
            try {
                list.add(freq.equals("0") ? 0 : cpuFreq.getFreqs(core).indexOf(Utils.strToInt(freq)) + 1);
            } catch (NullPointerException ignored) {
            }
        }
    } else {
        list.add(value.equals("0") ? 0 : cpuFreq.getFreqs().indexOf(Utils.strToInt(value)) + 1);
    }
    return list;
}
 
Example 3
Source Project: kernel_adiutor   Source File: ParentFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void resetTranslations() {
    parentFragment.toolbar.setBackgroundColor(Color.TRANSPARENT);
    parentFragment.viewContainerBackground.setBackgroundColor(Color.TRANSPARENT);
    parentFragment.descriptionText.setVisibility(View.GONE);

    int orientation = Utils.getScreenOrientation(getActivity());
    float density = getResources().getDisplayMetrics().density;

    float tabsPadding = orientation == Configuration.ORIENTATION_PORTRAIT ? 0 : density * 48;
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) parentFragment.mTabs.getLayoutParams();
    layoutParams.setMargins((int) tabsPadding, 0, (int) tabsPadding, 0);
    parentFragment.mTabs.requestLayout();

    setPaddingRecyclerview(orientation, density);
    if (onScrollListener != null) onScrollListener.reset();
    layoutManager.scrollToPositionWithOffset(0, 0);
}
 
Example 4
private void modify(final String key, final String value) {
    mKey = key;
    mValue = value;
    ViewUtils.dialogEditTexts(key, value, getString(R.string.key), getString(R.string.value),
            (dialogInterface, i) -> {
            },
            (text, text2) -> {
                if (text.isEmpty()) {
                    Utils.toast(R.string.key_empty, getActivity());
                    return;
                }

                if (key != null) {
                    overwrite(key.trim(), value.trim(), text.trim(), text2.trim());
                } else {
                    add(text.trim(), text2.trim());
                }
            }, getActivity())
            .setOnDismissListener(dialogInterface -> {
                mKey = null;
                mValue = null;
            }).show();
}
 
Example 5
Source Project: kernel_adiutor   Source File: CPUVoltageFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int getSpan() {
    int orientation = Utils.getScreenOrientation(getActivity());
    if (Utils.isTablet(getActivity()))
        return orientation == Configuration.ORIENTATION_LANDSCAPE ? 6 : 5;
    return orientation == Configuration.ORIENTATION_LANDSCAPE ? 4 : 3;
}
 
Example 6
Source Project: KA27   Source File: CPUVoltageFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int getSpan() {
    int orientation = Utils.getScreenOrientation(getActivity());
    if (Utils.isTablet(getActivity()))
        return orientation == Configuration.ORIENTATION_LANDSCAPE ? 6 : 5;
    return orientation == Configuration.ORIENTATION_LANDSCAPE ? 4 : 3;
}
 
Example 7
@Override
protected void init() {
    super.init();

    addViewPagerFragment(DescriptionFragment.newInstance(
            getString(R.string.welcome), getString(R.string.data_sharing_summary)));
    addViewPagerFragment(DescriptionFragment.newInstance(
            getString(R.string.welcome),
            Utils.htmlFrom(getString(R.string.data_sharing_summary_link))));
}
 
Example 8
Source Project: kernel_adiutor   Source File: BootReceiver.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (Utils.getBoolean("emulateinit.d", false, context))
        context.startService(new Intent(context, InitdService.class));
    context.startService(new Intent(context, BootService.class));
    ProfileTileReceiver.publishProfileTile(new ProfileDB(context).getAllProfiles(), context);
}
 
Example 9
Source Project: KernelAdiutor   Source File: Gamma.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static boolean hasKGamma() {
    for (String file : sKGammaFiles) {
        if (Utils.existFile(file)) {
            return true;
        }
    }
    return false;
}
 
Example 10
Source Project: kernel_adiutor   Source File: GPU.java    License: Apache License 2.0 5 votes vote down vote up
public static List<String> getGpuGovernors() {
    if (GPU_AVAILABLE_GOVERNORS == null)
        for (String file : GPU_AVAILABLE_GOVERNORS_ARRAY)
            if (GPU_AVAILABLE_GOVERNORS == null)
                if (Utils.existFile(file)) {
                    String value = Utils.readFile(file);
                    if (value != null)
                        GPU_AVAILABLE_GOVERNORS = value.split(" ");
                        Collections.sort(Arrays.asList(GPU_AVAILABLE_GOVERNORS), String.CASE_INSENSITIVE_ORDER);
                }
    return new ArrayList<>(Arrays.asList(GPU_AVAILABLE_GOVERNORS == null ? GPU_GENERIC_GOVERNORS
            .split(" ") : GPU_AVAILABLE_GOVERNORS));
}
 
Example 11
Source Project: KA27   Source File: GPU.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean hasGpuMinFreq() {
    if (GPU_MIN_FREQ == null) {
        for (String file: GPU_MIN_FREQ_ARRAY)
            if (Utils.existFile(file)) GPU_MIN_FREQ = file;
    }
    return GPU_MIN_FREQ != null;
}
 
Example 12
Source Project: KernelAdiutor   Source File: T2w.java    License: GNU General Public License v3.0 5 votes vote down vote up
private T2w() {
    for (String file : mFiles) {
        if (Utils.existFile(file)) {
            FILE = file;
            break;
        }
    }
}
 
Example 13
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_downloads);

    initToolBar();

    SupportedDownloads.KernelContent content = new SupportedDownloads.KernelContent(getIntent().getStringExtra(JSON_INTENT));
    getSupportActionBar().setTitle(Utils.htmlFrom(content.getName()).toString());

    final ViewPager viewPager = findViewById(R.id.viewpager);

    LinkedHashMap<String, Fragment> items = new LinkedHashMap<>();

    List<SupportedDownloads.KernelContent.Feature> features = content.getFeatures();
    List<SupportedDownloads.KernelContent.Download> downloads = content.getDownloads();

    if (content.getShortDescription() != null && content.getLongDescription() != null) {
        items.put(getString(R.string.about), AboutFragment.newInstance(content));
    }

    if (features.size() > 0) {
        items.put(getString(R.string.features), FeaturesFragment.newInstance(features));
    }

    if (downloads.size() > 0) {
        items.put(getString(R.string.downloads), DownloadKernelFragment.newInstance(downloads));
    }

    viewPager.setOffscreenPageLimit(items.size());
    PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager(), items);
    viewPager.setAdapter(pagerAdapter);

    TabLayout tabLayout = findViewById(R.id.tablayout);
    tabLayout.setupWithViewPager(viewPager);

    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
}
 
Example 14
Source Project: KernelAdiutor   Source File: KSM.java    License: GNU General Public License v3.0 5 votes vote down vote up
private KSM() {
    for (String file : mParent) {
        if (Utils.existFile(file)) {
            PARENT = file;
            break;
        }
    }
}
 
Example 15
Source Project: KA27   Source File: Misc.java    License: Apache License 2.0 5 votes vote down vote up
public static void setVibration(int value, Context context) {
    String enablePath = VIB_ENABLE;
    boolean enable = Utils.existFile(enablePath);
    if (enable) Control.runCommand("1", enablePath, Control.CommandType.GENERIC, context);
    Control.runCommand(String.valueOf(value), VIBRATION_PATH, Control.CommandType.GENERIC, context);
    if (Utils.existFile(VIB_LIGHT))
        Control.runCommand(String.valueOf(value - 300 < 116 ? 116 : value - 300), VIB_LIGHT,
            Control.CommandType.GENERIC, context);
    if (enable) Control.runCommand("0", enablePath, Control.CommandType.GENERIC, context);
}
 
Example 16
Source Project: KernelAdiutor   Source File: Gamma.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static String getRedGreys() {
    return Utils.readFile(GAMMACONTROL_RED_GREYS);
}
 
Example 17
Source Project: KA27   Source File: Battery.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean hasBclHotplug() {
    return Utils.existFile(BCL_HOTPLUG);
}
 
Example 18
Source Project: KernelAdiutor   Source File: MSMThermal.java    License: GNU General Public License v3.0 4 votes vote down vote up
public int getMinFreqIndex() {
    return Utils.strToInt(Utils.readFile(MSM_THERMAL_MIN_FREQ_INDEX));
}
 
Example 19
Source Project: kernel_adiutor   Source File: CPUHotplug.java    License: Apache License 2.0 4 votes vote down vote up
public static int getMsmHotplugSuspendFreq() {
    return Utils.stringToInt(Utils.readFile(MSM_HOTPLUG_SUSPEND_FREQ_FILE));
}
 
Example 20
Source Project: KA27   Source File: CPUHotplug.java    License: Apache License 2.0 4 votes vote down vote up
public static int getIntelliPlugThresold() {
    String file = HOTPLUG_INTELLI_PLUG_THRESHOLD;
    if (TYPE == INTELLIPLUG_TYPE.INTELLIPLUG_5) file = HOTPLUG_INTELLI_PLUG_5_THRESHOLD;
    return Utils.stringToInt(Utils.readFile(file));
}
 
Example 21
Source Project: KernelAdiutor   Source File: LazyPlug.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static int getHysteresis() {
    return Utils.strToInt(Utils.readFile(HYSTERESIS));
}
 
Example 22
Source Project: kernel_adiutor   Source File: CPUHotplug.java    License: Apache License 2.0 4 votes vote down vote up
public static void setMBHotplugCpusBoosted(int value, Context context) {
    Control.runCommand(String.valueOf(value), Utils.getsysfspath(MB_HOTPLUG_ARRAY) + "/" + MB_CPUS_BOOSTED, Control.CommandType.GENERIC, context);
}
 
Example 23
Source Project: KernelAdiutor   Source File: MSMThermal.java    License: GNU General Public License v3.0 4 votes vote down vote up
public boolean hasThermalLimitHigh() {
    return Utils.existFile(getParent(PARAMETERS_THERMAL_LIMIT_HIGH));
}
 
Example 24
Source Project: kernel_adiutor   Source File: Wake.java    License: Apache License 2.0 4 votes vote down vote up
public static int getDT2WFeatherX() {
    return Utils.stringToInt(Utils.readFile(WAKE_DT2W_FEATHERX));
}
 
Example 25
Source Project: KernelAdiutor   Source File: CPUBoost.java    License: GNU General Public License v3.0 4 votes vote down vote up
public boolean hasCpuBoostDebugMask() {
    return Utils.existFile(CPU_BOOST_DEBUG_MASK);
}
 
Example 26
Source Project: KA27   Source File: CPUHotplug.java    License: Apache License 2.0 4 votes vote down vote up
public static int getMBHotplugPause() {
    return Utils.stringToInt(Utils.readFile(Utils.getsysfspath(MB_HOTPLUG_ARRAY) + "/" + MB_PAUSE));
}
 
Example 27
Source Project: kernel_adiutor   Source File: Thermal.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean hasFrancoThermalStageThree() {
    return Utils.existFile(THERMAL_FRANCO_STAGE_THREE);
}
 
Example 28
Source Project: KernelAdiutor   Source File: Temperature.java    License: GNU General Public License v3.0 4 votes vote down vote up
private double getCPUTemp() {
    return (double) Utils.strToInt(Utils.readFile(CPU_NODE)) / CPU_OFFSET;
}
 
Example 29
Source Project: KernelAdiutor   Source File: AlucardHotplug.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static boolean supported() {
    return Utils.existFile(ALUCARD_HOTPLUG);
}
 
Example 30
Source Project: KA27   Source File: CPUVoltageFragment.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void init(Bundle savedInstanceState) {
    super.init(savedInstanceState);
    SharedPreferences storedvoltagetable = getContext().getSharedPreferences("voltage_table", 0);
    for (Map.Entry entry: storedvoltagetable.getAll().entrySet())
        voltagetable.put(entry.getKey().toString(), entry.getValue().toString());

    Log.i(Constants.TAG, "Volt Table: " + voltagetable);

    mVoltageCard = new EditTextCardView.DEditTextCard[CPUVoltage.getFreqs().size()];
    List < String > voltages = CPUVoltage.getVoltages();
    List < String > frequencies = CPUVoltage.getFreqs();
    if (voltages.isEmpty()) return;

    if (CPUVoltage.hasOverrideVmin()) {
        mOverrideVminCard = new SwitchCardView.DSwitchCard();
        mOverrideVminCard.setTitle(getString(R.string.override_vmin));
        mOverrideVminCard.setDescription(getString(R.string.override_vmin_summary));
        mOverrideVminCard.setChecked(CPUVoltage.isOverrideVminActive());
        mOverrideVminCard.setFullSpan(true);
        mOverrideVminCard.setOnDSwitchCardListener(this);

        addView(mOverrideVminCard);
    }

    for (int i = 0; i < frequencies.size(); i++) {
        mVoltageCard[i] = new EditTextCardView.DEditTextCard();
        String freq = CPUVoltage.isVddVoltage() ? String.valueOf(Utils.stringToInt(frequencies.get(i)) / 1000) : frequencies.get(i);
        mVoltageCard[i].setTitle(freq + getString(R.string.mhz));

        if (voltagetable.get(frequencies.get(i)) != null) {
            int stock = Integer.parseInt(voltagetable.get(frequencies.get(i)));
            int current = Integer.parseInt(voltages.get(i));
            String diff;
            if (stock > current) {
                diff = "(-" + (stock - current) + ")";
            } else if (stock < current) {
                diff = "(+" + (current - stock) + ")";
            } else {
                diff = "";
            }
            mVoltageCard[i].setDescription(voltages.get(i) + getString(R.string.mv) + diff);
        } else {
            mVoltageCard[i].setDescription(voltages.get(i) + getString(R.string.mv));
        }
        mVoltageCard[i].setValue(voltages.get(i));
        mVoltageCard[i].setBase(getString(R.string.mv));
        mVoltageCard[i].setOnDEditTextCardListener(new EditTextCardView.DEditTextCard.OnDEditTextCardListener() {
            @Override
            public void onApply(EditTextCardView.DEditTextCard dEditTextCard, String value) {
                List < String > freqs = CPUVoltage.getFreqs();

                for (int i = 0; i < mVoltageCard.length; i++)
                    if (dEditTextCard == mVoltageCard[i])
                        CPUVoltage.setVoltage(freqs.get(i), value, getActivity());

                dEditTextCard.setDescription(value + getString(R.string.mv));
                refresh();
            }
        });

        addView(mVoltageCard[i]);
    }

}