Hi guys;
Anyone here running this app on Pixel 2 XL? as I'm having
problem with it. It won't apply at boot and "KA-mod" stopped
working warning on screen shows up every time after reboot!
Thank you.
Hmm, it would probably be difficult to get a log in that case. In KA-Mod's Settings you can output different log files. Maybe do that right after booting and error message. Post a link or attachment (but please not pasted into a post).
I take it the app has storage permission granted?
Could also change the delay from default (5 seconds?) to 10.
Once saw a tip a long time ago to not have KA battery optimized. Probably not applicable to at-boot issues but it won't hurt to see.
Just throwing things out there.
EDIT: I/You/We should've searched first. It's a known issue it seems and has been mentioned before. No resolution that I know of.
Moto G5s Plus XT1806, PixelExperience Oreo, MultiROM, Tapatalk 4.9.5
Hmm, it would probably be difficult to get a log in that case. In KA-Mod's Settings you can output different log files. Maybe do that right after booting and error message. Post a link or attachment (but please not pasted into a post).
I take it the app has storage permission granted?
Could also change the delay from default (5 seconds?) to 10.
Once saw a tip a long time ago to not have KA battery optimized. Probably not applicable to at-boot issues but it won't hurt to see.
Just throwing things out there.
EDIT: I/You/We should've searched first. It's a known issue it seems and has been mentioned before. No resolution that I know of.
Moto G5s Plus XT1806, PixelExperience Oreo, MultiROM, Tapatalk 4.9.5
A standard logcat actually sounds perfect for this case.
[...]
<!-- SELinux Tile -->
<service
android:name="com.kerneladiutormod.reborn.services.SELinuxQSTileService"
android:icon="@drawable/ic_selinux_enf"
android:label="@string/selinux_tile"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
<meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
android:value="true" />
</service>
[...]
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,1L3,5v6c0,5.55 3.84,10.74 9,12 5.16,-1.26 9,-6.45 9,-12L21,5l-9,-4zM12,11.99h7c-0.53,4.12 -3.28,7.79 -7,8.94L12,12L5,12L5,6.3l7,-3.11v8.8z"/>
</vector>
<string name="selinux_tile">SELinux</string>
I would suggest to not be reliant on another app (ie KAMod), and shell out to an SU shell and run the command setenforce,
How to have a SELinux qsTile ?
I use Android Studio on Windows 10
in AndroidManifest.xml
Code:[...] <!-- SELinux Tile --> <service android:name="com.kerneladiutormod.reborn.services.SELinuxQSTileService" android:icon="@drawable/ic_selinux_enf" android:label="@string/selinux_tile" android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> <intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter> <meta-data android:name="android.service.quicksettings.ACTIVE_TILE" android:value="true" /> </service> [...]
a Vector Asset (icon) in "drawable" folder
ic_selinux_enf.xml
Code:<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#FF000000" android:pathData="M12,1L3,5v6c0,5.55 3.84,10.74 9,12 5.16,-1.26 9,-6.45 9,-12L21,5l-9,-4zM12,11.99h7c-0.53,4.12 -3.28,7.79 -7,8.94L12,12L5,12L5,6.3l7,-3.11v8.8z"/> </vector>
a string in strings.xml
or better... a string that change: Permissive / EnforcingCode:<string name="selinux_tile">SELinux</string>
but how to have it?
but SELinuxQSTileService.java?
I'm not able to write it
This looks great so far!
Do you have a github repo with your changes? I'd happily review your java code if you want help with it.
package com.kerneladiutormod.reborn.services;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.support.annotation.RequiresApi;
import com.kerneladiutormod.reborn.R;
import com.kerneladiutormod.reborn.utils.root.Control;
import static com.kerneladiutormod.reborn.utils.Constants.SETENFORCE;
import static com.kerneladiutormod.reborn.utils.kernel.Misc.isSELinuxActive;
@RequiresApi(api = Build.VERSION_CODES.N)
public class SELinuxQSTileService extends TileService {
private Context context;
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onTileAdded() {
tileSELinuxUpdate(getQsTile());
}
@Override
public void onTileRemoved() {
}
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onClick() {
tileSELinuxToggle(getQsTile());
}
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onStartListening () {
tileSELinuxUpdate(getQsTile());
}
@Override
public void onStopListening () {
}
@TargetApi(Build.VERSION_CODES.N)
private void tileSELinuxUpdate (Tile qsTile) {
Icon icon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_selinux);
if (isSELinuxActive()) {
if (qsTile.getState() == Tile.STATE_INACTIVE) {
qsTile.setState(Tile.STATE_ACTIVE);
}
}
if (!isSELinuxActive()) {
if (qsTile.getState() == Tile.STATE_ACTIVE) {
qsTile.setState(Tile.STATE_INACTIVE);
}
}
getQsTile().setIcon(icon);
getQsTile().updateTile();
}
@RequiresApi(api = Build.VERSION_CODES.N)
private void tileSELinuxToggle (Tile qsTile) {
if (isSELinuxActive() && qsTile.getState() == Tile.STATE_ACTIVE) {
Control.runCommand("0", SETENFORCE, Control.CommandType.SHELL, context);
}
else if (!isSELinuxActive() && qsTile.getState() == Tile.STATE_INACTIVE) {
Control.runCommand("1", SETENFORCE, Control.CommandType.SHELL, context);
}
try{
// Pause momentarily for sysfs changes
// This should be done differently, but this will work for now.
Thread.sleep(100);
}
catch(InterruptedException e){
}
tileSELinuxUpdate(qsTile);
}
}
it IS shelling out to a command shell. I didn't see that previouslyI'm not able to write java...
but I used as Model HBMQSTileService .
My code is:
app/src/main/java/com/kerneladiutormod/reborn/services/SELinuxQSTileService.java
Code:... Control.runCommand("0", SETENFORCE, Control.CommandType.SHELL, context); ...
To try and debug the issue, temporarily test increasing the Thread.sleep to something like 500 and see if things improve. The tile update may be occurring before the command shell command has completed being actioned.With this code I can change Permissive/Enforcing ...
but Enable/disable tile's color isn't always correct
Any help is appreciated
Code:... try{ // Pause momentarily for sysfs changes [B][COLOR="Orange"]// This should be done differently, but this will work for now.[/COLOR][/B] Thread.sleep([COLOR="Red"][B]100[/B][/COLOR]); } ...
I made it... but it don't solve.To try and debug the issue, temporarily test increasing the Thread.sleep to something like 500 and see if things improve.
Are you speaking about thisThe tile update may be occurring before the command shell command has completed being actioned.
}
tileSELinuxUpdate(qsTile);
}
Doh! Did it appear to make ANY difference to its reliability?
Yes.Are you speaking about this
at the java's end?Code:} tileSELinuxUpdate(qsTile); }
My next pass would be to add logging to actually see what is happening, when the code is running on a device. I would suggest to add logs before and after each line you are not sure what is happening, to see where its not acting as expected.
import android.util.Log;
Log.e(TAG, "SELinuxQS: Hello there: MyVal=true");
@TargetApi(Build.VERSION_CODES.N)
private void tileSELinuxUpdate (Tile qsTile) {
[COLOR="darkgreen"]Log.e(TAG, "SELinuxQS: tileSELinuxUpdate ENTRY");[/COLOR]
Icon icon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_selinux);
if (isSELinuxActive()) {
[COLOR="darkgreen"]Log.e(TAG, "SELinuxQS: isSELinuxActive()=true");[/COLOR]
if (qsTile.getState() == Tile.STATE_INACTIVE) {
qsTile.setState(Tile.STATE_ACTIVE);
[COLOR="darkgreen"]Log.e(TAG, "SELinuxQS: qsTile.getState() == Tile.STATE_ACTIVE");[/COLOR]
}
}
if (!isSELinuxActive()) {
[COLOR="darkgreen"]Log.e(TAG, "SELinuxQS: isSELinuxActive()=false");[/COLOR]
if (qsTile.getState() == Tile.STATE_ACTIVE) {
qsTile.setState(Tile.STATE_INACTIVE);
[COLOR="darkgreen"]Log.e(TAG, "SELinuxQS: qsTile.getState() == Tile.STATE_INACTIVE");[/COLOR]
}
}
getQsTile().setIcon(icon);
getQsTile().updateTile();
[COLOR="DarkGreen"]Log.e(TAG, "SELinuxQS: tileSELinuxUpdate EXIT");[/COLOR]
}
I see no difference
It's not simple for meMy next pass would be to add logging to actually see what is happening, ...
<meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
android:value="[B]false[/B]" />
Actually, are you sure that the line "Icon icon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_selinux);" is correct? It appears on first glance to be getting the same icon regardless of the SELinux State Maybe that should be within the if clauses as well to get a different resource depending on the state.
private Icon icon;
package com.kerneladiutormod.reborn.services;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.util.Log;
import com.kerneladiutormod.reborn.R;
import com.kerneladiutormod.reborn.utils.Constants;
import com.kerneladiutormod.reborn.utils.root.Control;
import java.util.Locale;
import static com.kerneladiutormod.reborn.utils.Constants.SETENFORCE;
@TargetApi(Build.VERSION_CODES.N)
public class SELinuxQSTileService extends TileService {
private static final String SERVICE_STATUS_FLAG = "serviceStatus";
private static final String PREFERENCES_KEY = "com.google.android_quick_settings";
protected Context context;
@Override
public void onTileAdded() {
Log.d("QS", "SELinux - Tile added");
tileSELinuxUpdate();
}
@Override
public void onTileRemoved() {
Log.d("QS", "SELinux - Tile removed");
}
@Override
public void onClick() {
Log.d("QS", "SELinux - Tile tapped");
tileSELinuxUpdate();
}
@Override
public void onStartListening () {
Log.d("QS", "SELinux - Start listening");
tileSELinuxUpdate();
}
@Override
public void onStopListening () {
Log.d("QS", "SELinux - Stop Listening");
}
private void tileSELinuxUpdate () {
Tile tile = this.getQsTile();
boolean isActive = getServiceStatus();
Icon newIcon;
String newLabel;
int newState;
// Change the tile to match the service status.
if (isActive) {
Log.i(Constants.TAG + ": " + getClass().getSimpleName(), "SELinux - Set Enforcing");
newLabel = String.format(Locale.US,
"%s %s",
getString(R.string.tile_label),
getString(R.string.service_active));
newIcon = Icon.createWithResource(getApplicationContext(),
R.drawable.ic_selinux_enf);
newState = Tile.STATE_ACTIVE;
Control.runCommand("1", SETENFORCE, Control.CommandType.SHELL, context);
} else {
Log.i(Constants.TAG + ": " + getClass().getSimpleName(), "SELinux - Set Permissive");
newLabel = String.format(Locale.US,
"%s %s",
getString(R.string.tile_label),
getString(R.string.service_inactive));
newIcon =
Icon.createWithResource(getApplicationContext(),
R.drawable.ic_selinux);
newState = Tile.STATE_INACTIVE;
Control.runCommand("0", SETENFORCE, Control.CommandType.SHELL, context);
}
// Change the UI of the tile.
tile.setLabel(newLabel);
tile.setIcon(newIcon);
tile.setState(newState);
// Need to call updateTile for the tile to pick up changes.
tile.updateTile();
}
// Access storage to see how many times the tile
// has been tapped.
private boolean getServiceStatus() {
SharedPreferences prefs =
getApplicationContext()
.getSharedPreferences(PREFERENCES_KEY, MODE_PRIVATE);
boolean isActive = prefs.getBoolean(SERVICE_STATUS_FLAG, false);
isActive = !isActive;
prefs.edit().putBoolean(SERVICE_STATUS_FLAG, isActive).apply();
return isActive;
}
}
I had a quick read, and the only issue I think I can see is that you assume that the setenforce command actually worked. If you were to un-root your device, you should not be able to change the SELinux status, but I think your tile will still show/think its worked. Also, even if you are rooted and it succeeds, it will actually show the change as being successful, possibly before it is actually completed.
Yes I Know
It Will Be Fixed In Next Update
But Until Then You Can Enjoy Big.little Core in Your Non-Big.little Core Phn:laugh: