Hello! I can not overcome the error. After several updates of the fragment (4 elements are updated immediately), it hangs up and then gives the following message:
Skipped 2137 frames! The application may be doing too much work on its main thread and after that the fragment resets all UI settings.
Java code
if (RootTools.isBusyboxAvailable()) { if (RootTools.isRootAvailable()) { if (RootTools.isAccessGiven()) { Command command1 = new Command(0, "pgrep rngd") { @Override public void commandOutput(int id, String line) { super.commandOutput(id, line); if (line.matches("[0-9]+")) { entropystatus = (TextView) getActivity().findViewById(R.id.entropystatus); entropystatus.setText("СТАТУС СЕРВИСА: ВКЛЮЧЕН"); entropystatus.setBackgroundResource(R.drawable.roundbuttongood); startentropy = (Button) getActivity().findViewById(R.id.startentropy); startentropy.setBackgroundResource(R.drawable.roundbuttonfuck); startentropy.setEnabled(false); startentropy.setTextColor(Color.WHITE); stopentropy = (Button) getActivity().findViewById(R.id.stopentropy); stopentropy.setBackgroundResource(R.drawable.roundbuttoncal); stopentropy.setEnabled(true); stopentropy.setTextColor(Color.WHITE); stopentropy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (RootTools.isBusyboxAvailable()) { if (RootTools.isRootAvailable()) { if (RootTools.isAccessGiven()) { Command command1 = new Command(0, "entropy_disable"); try { Toast.makeText(getActivity(), "Сервис остановлен!", Toast.LENGTH_SHORT).show(); RootTools.getShell(true).add(command1); } catch (IOException | RootDeniedException | TimeoutException ex) { ex.printStackTrace(); Toast.makeText(getActivity(), "ОШИБКА. СВЯЖИТЕСЬ С РАЗРАБОТЧИКОМ", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getActivity(), "ОШИБКА! ", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getActivity(), "ОШИБКА!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getActivity(), "ОШИБКА! НЕ УСТАНОВЛЕН BUSYBOX!", Toast.LENGTH_SHORT).show(); RootTools.offerBusyBox(getActivity()); } } }); } } @Override public void commandCompleted(int id, int exitcode) { super.commandCompleted(id, exitcode); if (exitcode==1) { entropystatus = (TextView) getActivity().findViewById(R.id.entropystatus); entropystatus.setText("СТАТУС СЕРВИСА: ВЫКЛЮЧЕН"); entropystatus.setBackgroundResource(R.drawable.roundbuttonbad); stopentropy = (Button) getActivity().findViewById(R.id.stopentropy); stopentropy.setBackgroundResource(R.drawable.roundbuttonfuck); stopentropy.setEnabled(false); stopentropy.setTextColor(Color.WHITE); startentropy = (Button) getActivity().findViewById(R.id.startentropy); startentropy.setBackgroundResource(R.drawable.roundbuttoncal); startentropy.setEnabled(true); startentropy.setTextColor(Color.WHITE); startentropy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ if (RootTools.isBusyboxAvailable()) { if (RootTools.isRootAvailable()) { if (RootTools.isAccessGiven()) { Command command1 = new Command(0, "entropy_enabler"); try { Toast.makeText(getActivity(), "Сервис запущен!", Toast.LENGTH_SHORT).show(); RootTools.getShell(true).add(command1); } catch (IOException | RootDeniedException | TimeoutException ex) { ex.printStackTrace(); Toast.makeText(getActivity(), "ОШИБКА. СВЯЖИТЕСЬ С РАЗРАБОТЧИКОМ", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getActivity(), "ОШИБКА! ", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getActivity(), "ОШИБКА!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getActivity(), "ОШИБКА! НЕ УСТАНОВЛЕН BUSYBOX!", Toast.LENGTH_SHORT).show(); RootTools.offerBusyBox(getActivity()); } } }); } } }; try { RootTools.getShell(true).add(command1); } catch (IOException | RootDeniedException | TimeoutException ex) { ex.printStackTrace(); } } else { } } else { } } else { RootTools.offerBusyBox(getActivity()); }
Layout code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="1"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="" android:id="@+id/entropystatus" android:layout_weight="0.04" android:gravity="center_vertical|center|center_horizontal" android:textColor="#ffffff" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Entropy Generator позволяет ускорить работу устройства путем выполнения специальных операций в /dev/random. Учтите, что данная утилита действительно полезна только для старых версий Android (ниже 4.4), на Android 4.4-6.0 она, естественно, работает, но существенного эффекта прироста производительности Вы скорее всего не заметите" android:id="@+id/textView33" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Сначала, если требуется, установите библиотеку по работе с Entropy, потом чтобы включить Entropy Generator, нажмите соответствующую кнопку\n\n" android:id="@+id/textView35" /> <Button android:layout_width="330dp" android:layout_height="55dp" android:text="Установить библиотеку работы с Entropy Generator\n" android:id="@+id/entropy" android:layout_gravity="top|center_horizontal" android:layout_marginBottom="10dp" android:gravity="center_vertical|center|center_horizontal" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:text="Статус кнопки обновляется только после перезагрузки страницы" android:id="@+id/textView9" android:layout_gravity="center_horizontal" android:layout_marginTop="-10dp" android:layout_marginBottom="10dp" android:gravity="center_vertical|center|center_horizontal" android:textSize="10dp" /> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.03"> <Button android:layout_width="162dp" android:layout_height="wrap_content" android:text="Запустить сервис" android:id="@+id/startentropy" android:layout_weight="0.04" android:layout_gravity="left|top" /> <Button android:layout_width="159dp" android:layout_height="wrap_content" android:text="Остановить сервис" android:id="@+id/stopentropy" android:layout_weight="0.04" android:layout_gravity="right|top" /> </FrameLayout> <Button android:layout_width="322dp" android:layout_height="wrap_content" android:text="Удалить Entropy Generator из системы" android:id="@+id/delete" android:layout_gravity="center_horizontal" android:layout_weight="0.04" android:layout_marginTop="10dp" /> </LinearLayout>
Tried to hang UI changes of each element on:
getActivity().runOnUiThread(new Runnable() { @Override public void run() { } });
Does not help.