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

Commit 00afd495 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Properly check for changes in CellSignalState

Make the CellSignalState class immutable. Provide a method for changing
the visibility from Java (by providing a copy if it actually changes).

Test: atest
Test: manual
Fixes: 148957619
Change-Id: If2070113bc379a53c207f4ca94dc1f741c608386
parent ca854b42
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
  ~ limitations under the License
  -->

<com.android.systemui.qs.QSCarrier
<com.android.systemui.qs.carrier.QSCarrier
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linear_carrier"
    android:layout_width="wrap_content"
@@ -46,4 +46,4 @@
        android:singleLine="true"
        android:maxEms="7"/>

</com.android.systemui.qs.QSCarrier>
 No newline at end of file
</com.android.systemui.qs.carrier.QSCarrier>
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
  -->

<!-- Extends LinearLayout -->
<com.android.systemui.qs.QSCarrierGroup
<com.android.systemui.qs.carrier.QSCarrierGroup
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/qs_mobile"
    android:layout_width="0dp"
@@ -71,4 +71,4 @@
        android:layout_weight="1"
        android:visibility="gone"/>

</com.android.systemui.qs.QSCarrierGroup>
 No newline at end of file
</com.android.systemui.qs.carrier.QSCarrierGroup>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.qs.QSDetail.Callback;
import com.android.systemui.qs.carrier.QSCarrierGroup;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.qs;

import com.android.systemui.R;
import com.android.systemui.qs.carrier.QSCarrierGroupController;

import javax.inject.Inject;

+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.qs.carrier

/**
 * Represents the state of cell signal for a particular slot.
 *
 * To be used between [QSCarrierGroupController] and [QSCarrier].
 */
data class CellSignalState(
    @JvmField val visible: Boolean = false,
    @JvmField val mobileSignalIconId: Int = 0,
    @JvmField val contentDescription: String? = null,
    @JvmField val typeContentDescription: String? = null,
    @JvmField val roaming: Boolean = false
) {
    /**
     * Changes the visibility of this state by returning a copy with the visibility changed.
     *
     * If the visibility would not change, the same state is returned.
     *
     * @param visible the new visibility state
     * @return `this` if `this.visible == visible`. Else, a new copy with the visibility changed.
     */
    fun changeVisibility(visible: Boolean): CellSignalState {
        if (this.visible == visible) return this
        else return copy(visible = visible)
    }
}
 No newline at end of file
Loading