Merge "Fix a bug that the QuickAccessWalletTile displaying packageName as title." into sc-dev
This commit is contained in:
@@ -153,9 +153,25 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private CharSequence getServiceLabelSafe() {
|
||||||
|
try {
|
||||||
|
return mController.getWalletClient().getServiceLabel();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
Log.e(TAG, "Failed to get the service label safely, recreating wallet client", e);
|
||||||
|
mController.reCreateWalletClient();
|
||||||
|
try {
|
||||||
|
return mController.getWalletClient().getServiceLabel();
|
||||||
|
} catch (RuntimeException e2) {
|
||||||
|
Log.e(TAG, "The QAW service label is broken.", e2);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleUpdateState(State state, Object arg) {
|
protected void handleUpdateState(State state, Object arg) {
|
||||||
CharSequence label = mController.getWalletClient().getServiceLabel();
|
CharSequence label = getServiceLabelSafe();
|
||||||
state.label = label == null ? mLabel : label;
|
state.label = label == null ? mLabel : label;
|
||||||
state.contentDescription = state.label;
|
state.contentDescription = state.label;
|
||||||
Drawable tileIcon = mController.getWalletClient().getTileIcon();
|
Drawable tileIcon = mController.getWalletClient().getTileIcon();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import static junit.framework.TestCase.assertTrue;
|
|||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
@@ -255,6 +256,19 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
|
|||||||
assertThat(nextStartedIntent.getComponent().getClassName()).isEqualTo(walletClassName);
|
assertThat(nextStartedIntent.getComponent().getClassName()).isEqualTo(walletClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetServiceLabelUnsafe_recreateWalletClient() {
|
||||||
|
doAnswer(invocation -> {
|
||||||
|
throw new Exception("Bad service label.");
|
||||||
|
}).when(mQuickAccessWalletClient).getServiceLabel();
|
||||||
|
|
||||||
|
QSTile.State state = new QSTile.State();
|
||||||
|
|
||||||
|
mTile.handleUpdateState(state, null);
|
||||||
|
|
||||||
|
verify(mController).reCreateWalletClient();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleUpdateState_updateLabelAndIcon() {
|
public void testHandleUpdateState_updateLabelAndIcon() {
|
||||||
QSTile.State state = new QSTile.State();
|
QSTile.State state = new QSTile.State();
|
||||||
|
|||||||
Reference in New Issue
Block a user