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

Commit 5a05d4f5 authored by Steve Kondik's avatar Steve Kondik Committed by Ricardo Cerqueira
Browse files

qs: Add torch and GPS tiles by default if supported

 * New configuration variable config_enableTorch has been moved from
   the settings app that devices should overlay onto.

Change-Id: I2e4cb81390548cf055eae2836280fe9bdc65f0b0
parent 67b1b56b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ public class QSConstants {
            TILES_DEFAULT.add(TILE_SETTINGS);
            TILES_DEFAULT.add(TILE_WIFI);
            TILES_DEFAULT.add(TILE_MOBILEDATA);
            TILES_DEFAULT.add(TILE_GPS);
            TILES_DEFAULT.add(TILE_TORCH);
            TILES_DEFAULT.add(TILE_BATTERY);
            TILES_DEFAULT.add(TILE_AIRPLANE);
            TILES_DEFAULT.add(TILE_BLUETOOTH);
+10 −0
Original line number Diff line number Diff line
package com.android.internal.util.cm;

import android.R;
import android.bluetooth.BluetoothAdapter;
import android.content.ContentResolver;
import android.content.Context;
@@ -51,6 +52,15 @@ public class QSUtils {
            final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
            return (tm.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) || tm.getLteOnGsmMode() != 0;
        }

        public static boolean deviceSupportsGps(Context context) {
            return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);
        }

        public static boolean deviceSupportsTorch(Context context) {
            return context.getResources().getBoolean(com.android.internal.R.bool.config_enableTorch);
        }

        public static boolean adbEnabled(ContentResolver resolver) {
            return (Settings.Global.getInt(resolver, Settings.Global.ADB_ENABLED, 0)) == 1;
        }
+3 −0
Original line number Diff line number Diff line
@@ -1375,4 +1375,7 @@
    <!-- The list of components which should be automatically disabled. -->
    <string-array name="config_disabledComponents" translatable="false">
    </string-array>

    <!-- Device supports LED flashlight -->
    <bool name="config_enableTorch">false</bool>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -1839,4 +1839,6 @@
  <!-- Package Manager -->
  <java-symbol type="array" name="config_disabledComponents" />

  <!-- LED flashlight -->
  <java-symbol type="bool" name="config_enableTorch" />
</resources>
+10 −0
Original line number Diff line number Diff line
@@ -134,6 +134,8 @@ public class QuickSettingsController {
        boolean bluetoothSupported = deviceSupportsBluetooth();
        boolean mobileDataSupported = deviceSupportsMobileData(mContext);
        boolean lteSupported = deviceSupportsLte(mContext);
        boolean gpsSupported = QSUtils.deviceSupportsGps(mContext);
        boolean torchSupported = QSUtils.deviceSupportsTorch(mContext);

        if (!bluetoothSupported) {
            TILES_DEFAULT.remove(TILE_BLUETOOTH);
@@ -149,6 +151,14 @@ public class QuickSettingsController {
            TILES_DEFAULT.remove(TILE_LTE);
        }

        if (!gpsSupported) {
            TILES_DEFAULT.remove(TILE_GPS);
        }

        if (!torchSupported) {
            TILES_DEFAULT.remove(TILE_TORCH);
        }

        // Read the stored list of tiles
        ContentResolver resolver = mContext.getContentResolver();
        LayoutInflater inflater = LayoutInflater.from(mContext);