Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bfe9a02b authored by Michael Bestas's avatar Michael Bestas Committed by Gerrit Code Review
Browse files

SystemUI: Hide perf profile tile on devices without perf profiles

Change-Id: If613557033c4b12fd21f5edfa0962b4fb9f4ad41
parent 1f73e252
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.PowerManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.telephony.TelephonyManager;
@@ -124,6 +125,9 @@ public class QSUtils {
                case QSConstants.TILE_AMBIENT_DISPLAY:
                    removeTile = !deviceSupportsDoze(context);
                    break;
                case QSConstants.TILE_PERFORMANCE:
                    removeTile = !deviceSupportsPowerProfiles(context);
                    break;

                case QSConstants.DYNAMIC_TILE_SU:
                    removeTile = !supportsRootAccess();
@@ -294,6 +298,11 @@ public class QSUtils {
        return !TextUtils.isEmpty(name);
    }

    public static boolean deviceSupportsPowerProfiles(Context context) {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        return pm.hasPowerProfiles();
    }

    private static boolean supportsRootAccess() {
        return Build.IS_DEBUGGABLE || "eng".equals(Build.TYPE);
    }
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ public class PerfProfileTile extends QSTile<PerfProfileTile.ProfileState> {

    @Override
    protected void handleUpdateState(ProfileState state, Object arg) {
        state.visible = true;
        state.visible = mPm.hasPowerProfiles();
        state.profile = arg == null ? getCurrentProfileIndex() : (Integer) arg;
        state.label = mEntries[state.profile];
        state.icon = getIconForState(state.profile);