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

Commit 670d3df1 authored by bmc08gt's avatar bmc08gt Committed by Gerrit Code Review
Browse files

SystemBars: Allow the StatusBarComponent be externally defined



* The default UI for fugu is a TV with no statusbar, however we allow for a full android
    experience with a mouse and keyboard as well.
* Allow ro.cm.statusBarComponent=<component> be set in the build prop to enable the desired statubar.

* A HomeSwitcher is to be created for TvSettings and will also set the STATUSBAR_COMPONENT Settings.dB value,
     depending on if LeanbackLauncher or Trebuchet is the default.

* Order of preference of components:
      -> Prop
      -> Database (System.STATUSBAR_COMPONENT)
      -> config value

Change-Id: I8c0c9bccf9283960abd40b55a7c9ff47e3a97317
Signed-off-by: default avatarbmc08gt <brandon.mcansh@gmail.com>
parent 65abb32d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -3534,6 +3534,13 @@ public final class Settings {
        public static final String VOLUME_KEYS_CONTROL_RING_STREAM =
                "volume_keys_control_ring_stream";

        /**
         * The statusbar configuration to be used for its creation in SystemUI
         * Fallback is the config_statusBarComponent value
         * @hide
         */
        public static final String STATUSBAR_COMPONENT = "statusbar_component";

        /**
         * Settings to backup. This is here so that it's in the same place as the settings
         * keys and easy to update.
+34 −1
Original line number Diff line number Diff line
@@ -16,8 +16,12 @@

package com.android.systemui.statusbar;

import android.content.ContentResolver;
import android.content.res.Configuration;
import android.os.SystemProperties;
import android.provider.Settings;
import android.provider.Settings.System;
import android.text.TextUtils;
import android.util.Log;

import com.android.systemui.R;
@@ -86,7 +90,7 @@ public class SystemBars extends SystemUI implements ServiceMonitor.Callbacks {

    private void createStatusBarFromConfig() {
        if (DEBUG) Log.d(TAG, "createStatusBarFromConfig");
        final String clsName = mContext.getString(R.string.config_statusBarComponent);
        final String clsName = getStatusBarComponent();
        if (clsName == null || clsName.length() == 0) {
            throw andLog("No status bar component configured", null);
        }
@@ -111,4 +115,33 @@ public class SystemBars extends SystemUI implements ServiceMonitor.Callbacks {
        Log.w(TAG, msg, t);
        throw new RuntimeException(msg, t);
    }

    /**
     * Retrieves the statusBarComponent from possible external definitions
     *
     * The property 'ro.cm.statusBarComponent' is preferred over other values, if exists
     * The System.STATUSBAR_COMPONENT value is preferred over the config, if exists
     * If the dB value and property value are both null, the fallback config_statusBarComponent
     * is used.
     */
    private String getStatusBarComponent() {
        ContentResolver resolver = mContext.getContentResolver();

        String componentPropValue = SystemProperties.get("ro.cm.statusBarComponent");
        String componentDbValue = Settings.System.getString(resolver, System.STATUSBAR_COMPONENT);

        String statusBarComponentPrefix = "com.android.systemui.statusbar.";

        if (!TextUtils.isEmpty(componentPropValue)) {
            if (DEBUG) Log.d(TAG, "using ro.cm.statusBarComponent value : " + componentPropValue);
            return statusBarComponentPrefix + componentPropValue;
        } else if (componentDbValue != null) {
            if (DEBUG) Log.d(TAG, "using STATUSBAR_COMPONENT value : " + componentDbValue);
            return statusBarComponentPrefix + componentDbValue;
        } else {
            // fallback to config value
            if (DEBUG) Log.d(TAG, "Prop and dB value null. Using fallback default component.");
            return mContext.getString(R.string.config_statusBarComponent);
        }
    }
}