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

Commit 31a58b31 authored by jianhuac's avatar jianhuac Committed by Linux Build Service Account
Browse files

Settings: show or hide Scheduled power on/off menu automatic

Show Scheduled power on/off menu if the 'TimerSwitch' enable
otherwise hide.

Change-Id: Ib47bd7465300df3a42afc396ca005ac094fe629e
parent 1dd4e50d
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.nfc.NfcAdapter;
@@ -225,6 +226,8 @@ public class SettingsActivity extends SettingsDrawerActivity

    private static final int REQUEST_SUGGESTION = 42;

    private static final String ACTION_TIMER_SWITCH = "qualcomm.intent.action.TIMER_SWITCH";

    private String mFragmentClass;
    private String mActivityAction;

@@ -1130,6 +1133,18 @@ public class SettingsActivity extends SettingsDrawerActivity
        // Reveal development-only quick settings tiles
        DevelopmentTiles.setTilesEnabled(this, showDev);

        // Show scheduled power on and off if support
        boolean showTimerSwitch = false;
        Intent intent = new Intent(ACTION_TIMER_SWITCH);
        List<ResolveInfo> infos = getBaseContext().getPackageManager()
                .queryIntentActivities(intent, 0);
        if (infos != null && !infos.isEmpty()) {
            showTimerSwitch = true;
        }
        setTileEnabled(new ComponentName(packageName,
                Settings.TimerSwitchSettingsActivity.class.getName()),
                showTimerSwitch, isAdmin, pm);

        if (UserHandle.MU_ENABLED && !isAdmin) {
            // When on restricted users, disable all extra categories (but only the settings ones).
            List<DashboardCategory> categories = getDashboardCategories();