Crash when enabling show_operator_name_in_statusbar_bool

type casting of customized textview into OperatorNameView
gives a ClassCastException. The reason is that ViewStub
and Textview have the same id.

Change the ViewStub name to solve this

Test: Manual
Bug: 254244187
Change-Id: Idf7c94a5a3e9e5ad637bef3d3031fa4ae65af710
This commit is contained in:
Karthik Krishnan
2023-04-13 14:43:31 +05:30
committed by Mattias Nilsson
parent b931d69bd2
commit 937c32796f
3 changed files with 5 additions and 4 deletions

View File

@@ -78,7 +78,7 @@
android:layout_width="match_parent"
android:clipChildren="false">
<ViewStub
android:id="@+id/operator_name"
android:id="@+id/operator_name_stub"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout="@layout/operator_name" />

View File

@@ -636,9 +636,9 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
private void initOperatorName() {
int subId = SubscriptionManager.getDefaultDataSubscriptionId();
if (mCarrierConfigTracker.getShowOperatorNameInStatusBarConfig(subId)) {
ViewStub stub = mStatusBar.findViewById(R.id.operator_name);
View view = mStatusBar.findViewById(R.id.operator_name);
mOperatorNameViewController =
mOperatorNameViewControllerFactory.create((OperatorNameView) stub.inflate());
mOperatorNameViewControllerFactory.create((OperatorNameView) view);
mOperatorNameViewController.init();
// This view should not be visible on lock-screen
if (mKeyguardStateController.isShowing()) {

View File

@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.phone.fragment.dagger;
import android.view.View;
import android.view.ViewStub;
import com.android.systemui.R;
import com.android.systemui.battery.BatteryMeterView;
@@ -95,7 +96,7 @@ public interface StatusBarFragmentModule {
@StatusBarFragmentScope
@Named(OPERATOR_NAME_VIEW)
static View provideOperatorNameView(@RootView PhoneStatusBarView view) {
return view.findViewById(R.id.operator_name);
return ((ViewStub) view.findViewById(R.id.operator_name_stub)).inflate();
}
/** */