Loading packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java +6 −2 Original line number Diff line number Diff line Loading @@ -345,8 +345,12 @@ public class TileServices extends IQSService.Stub { @Override public void onReceive(Context context, Intent intent) { if (TileService.ACTION_REQUEST_LISTENING.equals(intent.getAction())) { requestListening( (ComponentName) intent.getParcelableExtra(Intent.EXTRA_COMPONENT_NAME)); try { ComponentName c = intent.getParcelableExtra(Intent.EXTRA_COMPONENT_NAME); requestListening(c); } catch (ClassCastException ex) { Log.e(TAG, "Bad component name", ex); } } } }; Loading packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -27,7 +27,9 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Looper; Loading Loading @@ -142,6 +144,16 @@ public class TileServicesTest extends SysuiTestCase { assertTrue(captor.getValue().hasAction(TileService.ACTION_REQUEST_LISTENING)); } @Test public void testBadComponentName_doesntCrash() { ArgumentCaptor<BroadcastReceiver> captor = ArgumentCaptor.forClass(BroadcastReceiver.class); verify(mBroadcastDispatcher).registerReceiver(captor.capture(), any(), any(), eq( UserHandle.ALL)); Intent intent = new Intent(TileService.ACTION_REQUEST_LISTENING) .putExtra(Intent.EXTRA_COMPONENT_NAME, "abc"); captor.getValue().onReceive(mContext, intent); } @Test public void testRecalculateBindAllowance() { // Add some fake tiles. Loading Loading
packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java +6 −2 Original line number Diff line number Diff line Loading @@ -345,8 +345,12 @@ public class TileServices extends IQSService.Stub { @Override public void onReceive(Context context, Intent intent) { if (TileService.ACTION_REQUEST_LISTENING.equals(intent.getAction())) { requestListening( (ComponentName) intent.getParcelableExtra(Intent.EXTRA_COMPONENT_NAME)); try { ComponentName c = intent.getParcelableExtra(Intent.EXTRA_COMPONENT_NAME); requestListening(c); } catch (ClassCastException ex) { Log.e(TAG, "Bad component name", ex); } } } }; Loading
packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -27,7 +27,9 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Looper; Loading Loading @@ -142,6 +144,16 @@ public class TileServicesTest extends SysuiTestCase { assertTrue(captor.getValue().hasAction(TileService.ACTION_REQUEST_LISTENING)); } @Test public void testBadComponentName_doesntCrash() { ArgumentCaptor<BroadcastReceiver> captor = ArgumentCaptor.forClass(BroadcastReceiver.class); verify(mBroadcastDispatcher).registerReceiver(captor.capture(), any(), any(), eq( UserHandle.ALL)); Intent intent = new Intent(TileService.ACTION_REQUEST_LISTENING) .putExtra(Intent.EXTRA_COMPONENT_NAME, "abc"); captor.getValue().onReceive(mContext, intent); } @Test public void testRecalculateBindAllowance() { // Add some fake tiles. Loading