com.grarak.kerneladiutor.utils.Utils Java Examples

The following examples show how to use com.grarak.kerneladiutor.utils.Utils. 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 File: CPUBoost.java    From KernelAdiutor with 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 #2
Source File: MiscFragment.java    From kernel_adiutor with 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 #3
Source File: BuildpropFragment.java    From KernelAdiutor with GNU General Public License v3.0 6 votes vote down vote up
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 #4
Source File: ParentFragment.java    From kernel_adiutor with 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 #5
Source File: GPU.java    From KA27 with 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 #6
Source File: Misc.java    From KA27 with 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 #7
Source File: CPUVoltageFragment.java    From kernel_adiutor with 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 #8
Source File: DataSharingFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@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 #9
Source File: CPUVoltageFragment.java    From KA27 with 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 #10
Source File: KSM.java    From KernelAdiutor with 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 #11
Source File: DownloadsActivity.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@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 #12
Source File: T2w.java    From KernelAdiutor with 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
Source File: BootReceiver.java    From kernel_adiutor with 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 #14
Source File: Gamma.java    From KernelAdiutor with 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 #15
Source File: GPU.java    From kernel_adiutor with 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 #16
Source File: Screen.java    From KA27 with Apache License 2.0 4 votes vote down vote up
public static int getScreenContrast() {
    return Utils.stringToInt(Utils.readFile(SCREEN_KCAL_CTRL_CONT));
}
 
Example #17
Source File: VM.java    From kernel_adiutor with Apache License 2.0 4 votes vote down vote up
public static int getSwappiness() {
    return Utils.stringToInt(Utils.readFile(VM_SWAPPINESS));
}
 
Example #18
Source File: IO.java    From KernelAdiutor with GNU General Public License v3.0 4 votes vote down vote up
public boolean isIOStatsEnabled(Storage storage) {
    return Utils.readFile(getPath(storage, IOSTATS)).equals("1");
}
 
Example #19
Source File: AlucardHotplug.java    From KernelAdiutor with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isAlucardHotplugSuspendEnabled() {
    return Utils.readFile(ALUCARD_HOTPLUG_SUSPEND).equals("1");
}
 
Example #20
Source File: Misc.java    From KernelAdiutor with GNU General Public License v3.0 4 votes vote down vote up
public static List<String> getCpuQuietAvailableGovernors() {
    if (sCpuQuietAvailableGovernors == null) {
        sCpuQuietAvailableGovernors = Utils.readFile(CPU_QUIET_AVAILABLE_GOVERNORS).split(" ");
    }
    return new ArrayList<>(Arrays.asList(sCpuQuietAvailableGovernors));
}
 
Example #21
Source File: Battery.java    From KA27 with Apache License 2.0 4 votes vote down vote up
public static boolean hasChargingRate() {
    return Utils.existFile(CUSTOM_CHARGING_RATE);
}
 
Example #22
Source File: CPUHotplug.java    From KA27 with Apache License 2.0 4 votes vote down vote up
public static boolean hasDynPlugMinOnline() {
    return Utils.existFile(HOTPLUG_DYN_PLUG_MIN_ONLINE);
}
 
Example #23
Source File: CPUHotplug.java    From kernel_adiutor with Apache License 2.0 4 votes vote down vote up
public static boolean hasMakoHotplugMinCoresOnline() {
    return Utils.existFile(MAKO_HOTPLUG_MIN_CORES_ONLINE);
}
 
Example #24
Source File: CPUHotplug.java    From KA27 with Apache License 2.0 4 votes vote down vote up
public static boolean hasIntelliPlugMaxCpusOnlineSusp() {
    return Utils.existFile(HOTPLUG_INTELLI_PLUG_5_MAX_CPUS_ONLINE_SUSP);
}
 
Example #25
Source File: Screen.java    From KA27 with Apache License 2.0 4 votes vote down vote up
public static void setKGammaRed(String value, Context context) {
    if (Utils.existFile(K_GAMMA_RED))
        Control.runCommand(value, K_GAMMA_RED, Control.CommandType.GENERIC, context);
    else
        Control.runCommand(value, K_GAMMA_R, Control.CommandType.GENERIC, context);
}
 
Example #26
Source File: GPU.java    From KA27 with Apache License 2.0 4 votes vote down vote up
public static int getSimpleOndemandDownDiff() {
    return Utils.stringToInt(Utils.readFile(SIMPLE_ONDEMAND_DOWNDIFFERENTIAL));
}
 
Example #27
Source File: IO.java    From KA27 with Apache License 2.0 4 votes vote down vote up
public static boolean hasExternalStorage() {
    return Utils.existFile(IO_EXTERNAL_READ_AHEAD) ||
        Utils.existFile(IO_EXTERNAL_SCHEDULER);
}
 
Example #28
Source File: CPUHotplug.java    From kernel_adiutor with Apache License 2.0 4 votes vote down vote up
public static boolean hasBrickedDownLockDuration() {
    return Utils.existFile(Utils.getsysfspath(MB_HOTPLUG_ARRAY) + "/" + BRICKED_DOWN_LOCK_DURATION);
}
 
Example #29
Source File: CPUHotplug.java    From kernel_adiutor with 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 #30
Source File: MSMHotplug.java    From KernelAdiutor with GNU General Public License v3.0 4 votes vote down vote up
public boolean hasMsmHotplugFastLaneMinFreq() {
    return Utils.existFile(HOTPLUG_MSM_FAST_LANE_MIN_FREQ);
}