Merge "Add the no calling & SMS icons for Provider Model"
This commit is contained in:
committed by
Android (Google) Code Review
commit
60a6e3ae35
@@ -58,6 +58,7 @@
|
||||
<item><xliff:g id="id">@string/status_bar_hotspot</xliff:g></item>
|
||||
<item><xliff:g id="id">@string/status_bar_mobile</xliff:g></item>
|
||||
<item><xliff:g id="id">@string/status_bar_airplane</xliff:g></item>
|
||||
<item><xliff:g id="id">@string/status_bar_no_calling</xliff:g></item>
|
||||
<item><xliff:g id="id">@string/status_bar_battery</xliff:g></item>
|
||||
<item><xliff:g id="id">@string/status_bar_sensors_off</xliff:g></item>
|
||||
</string-array>
|
||||
@@ -94,6 +95,7 @@
|
||||
<string translatable="false" name="status_bar_microphone">microphone</string>
|
||||
<string translatable="false" name="status_bar_camera">camera</string>
|
||||
<string translatable="false" name="status_bar_airplane">airplane</string>
|
||||
<string translatable="false" name="status_bar_no_calling">no_calling</string>
|
||||
<string translatable="false" name="status_bar_sensors_off">sensors_off</string>
|
||||
<string translatable="false" name="status_bar_screen_record">screen_record</string>
|
||||
|
||||
|
||||
@@ -2947,6 +2947,7 @@
|
||||
<java-symbol type="string" name="status_bar_secure" />
|
||||
<java-symbol type="string" name="status_bar_clock" />
|
||||
<java-symbol type="string" name="status_bar_airplane" />
|
||||
<java-symbol type="string" name="status_bar_no_calling" />
|
||||
<java-symbol type="string" name="status_bar_mobile" />
|
||||
<java-symbol type="string" name="status_bar_ethernet" />
|
||||
<java-symbol type="string" name="status_bar_vpn" />
|
||||
|
||||
28
packages/SystemUI/res/drawable/ic_qs_no_calling_sms.xml
Normal file
28
packages/SystemUI/res/drawable/ic_qs_no_calling_sms.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10c0.34,0 0.68,-0.02 1.01,-0.05V20h-1v-0.04c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96H13v-2H9.66c-0.09,-0.66 -0.16,-1.32 -0.16,-2s0.07,-1.35 0.16,-2H21.8C20.87,5.44 16.83,2 11.99,2zM18.92,8h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56C16.43,5.07 17.96,6.35 18.92,8zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82C10.52,6.57 11.17,5.24 12,4.04zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2s0.06,1.34 0.14,2H4.26zM5.08,16h2.95c0.32,1.25 0.78,2.45 1.38,3.56C7.57,18.93 6.04,17.66 5.08,16zM8.03,8H5.08c0.96,-1.66 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8z"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M22,19.3v-0.9l-3.37,-2.25v-2.47C18.63,13.3 18.35,13 18,13s-0.63,0.3 -0.63,0.68v2.47L14,18.4v0.9l3.37,-1.12v2.48l-0.84,0.68V22L18,21.55L19.47,22v-0.67l-0.84,-0.68v-2.48L22,19.3z"/>
|
||||
</vector>
|
||||
@@ -43,6 +43,7 @@ import com.android.systemui.statusbar.StatusBarMobileView;
|
||||
import com.android.systemui.statusbar.StatusBarWifiView;
|
||||
import com.android.systemui.statusbar.StatusIconDisplayable;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.NoCallingIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
|
||||
import java.util.List;
|
||||
@@ -62,6 +63,10 @@ public interface StatusBarIconController {
|
||||
public void setIcon(String slot, StatusBarIcon icon);
|
||||
public void setSignalIcon(String slot, WifiIconState state);
|
||||
public void setMobileIcons(String slot, List<MobileIconState> states);
|
||||
/**
|
||||
* Display the no calling & SMS icons.
|
||||
*/
|
||||
void setNoCallingIcons(String slot, List<NoCallingIconState> states);
|
||||
public void setIconVisibility(String slot, boolean b);
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.android.systemui.demomode.DemoModeController;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.StatusIconDisplayable;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.NoCallingIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
|
||||
@@ -216,6 +217,29 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a list of NoCallingIconStates, and show them in the same slot
|
||||
* @param slot StatusBar slot
|
||||
* @param states All of the no Calling & SMS icon states
|
||||
*/
|
||||
@Override
|
||||
public void setNoCallingIcons(String slot, List<NoCallingIconState> states) {
|
||||
Slot noCallingSlot = getSlot(slot);
|
||||
int slotIndex = getSlotIndex(slot);
|
||||
|
||||
for (NoCallingIconState state : states) {
|
||||
StatusBarIconHolder holder = noCallingSlot.getHolderForTag(state.subId);
|
||||
if (holder == null) {
|
||||
holder = StatusBarIconHolder.fromNoCallingState(mContext, state);
|
||||
holder.setVisible(state.visible);
|
||||
setIcon(slotIndex, holder);
|
||||
} else {
|
||||
holder.setVisible(state.visible);
|
||||
setIcon(slotIndex, holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExternalIcon(String slot) {
|
||||
int viewIndex = getViewIndex(getSlotIndex(slot), 0);
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.os.UserHandle;
|
||||
|
||||
import com.android.internal.statusbar.StatusBarIcon;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.NoCallingIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
|
||||
/**
|
||||
@@ -70,6 +71,18 @@ public class StatusBarIconHolder {
|
||||
return holder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new StatusBarIconHolder from a NoCallingIconState.
|
||||
*/
|
||||
public static StatusBarIconHolder fromNoCallingState(
|
||||
Context context, NoCallingIconState state) {
|
||||
StatusBarIconHolder holder = new StatusBarIconHolder();
|
||||
holder.mIcon = new StatusBarIcon(UserHandle.SYSTEM, context.getPackageName(),
|
||||
Icon.createWithResource(context, state.resId), 0, 0, null);
|
||||
holder.mTag = state.subId;
|
||||
return holder;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return mType;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
private final String mSlotWifi;
|
||||
private final String mSlotEthernet;
|
||||
private final String mSlotVpn;
|
||||
private final String mSlotNoCalling;
|
||||
|
||||
private final Context mContext;
|
||||
private final StatusBarIconController mIconController;
|
||||
@@ -66,6 +67,7 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
private boolean mWifiVisible = false;
|
||||
|
||||
private ArrayList<MobileIconState> mMobileStates = new ArrayList<MobileIconState>();
|
||||
private ArrayList<NoCallingIconState> mNoCallingStates = new ArrayList<NoCallingIconState>();
|
||||
private WifiIconState mWifiIconState = new WifiIconState();
|
||||
|
||||
public StatusBarSignalPolicy(Context context, StatusBarIconController iconController) {
|
||||
@@ -76,6 +78,7 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
mSlotWifi = mContext.getString(com.android.internal.R.string.status_bar_wifi);
|
||||
mSlotEthernet = mContext.getString(com.android.internal.R.string.status_bar_ethernet);
|
||||
mSlotVpn = mContext.getString(com.android.internal.R.string.status_bar_vpn);
|
||||
mSlotNoCalling = mContext.getString(com.android.internal.R.string.status_bar_no_calling);
|
||||
mActivityEnabled = mContext.getResources().getBoolean(R.bool.config_showActivity);
|
||||
|
||||
mIconController = iconController;
|
||||
@@ -197,6 +200,22 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoCallingStatus(boolean noCalling, int subId) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "setNoCallingStatus: "
|
||||
+ "noCalling = " + noCalling + ","
|
||||
+ "subId = " + subId);
|
||||
}
|
||||
NoCallingIconState state = getNoCallingState(subId);
|
||||
if (state == null) {
|
||||
return;
|
||||
}
|
||||
state.visible = noCalling;
|
||||
mIconController.setNoCallingIcons(
|
||||
mSlotNoCalling, NoCallingIconState.copyStates(mNoCallingStates));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
|
||||
int qsType, boolean activityIn, boolean activityOut,
|
||||
@@ -252,6 +271,16 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
}
|
||||
}
|
||||
|
||||
private NoCallingIconState getNoCallingState(int subId) {
|
||||
for (NoCallingIconState state : mNoCallingStates) {
|
||||
if (state.subId == subId) {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "Unexpected subscription " + subId);
|
||||
return null;
|
||||
}
|
||||
|
||||
private MobileIconState getState(int subId) {
|
||||
for (MobileIconState state : mMobileStates) {
|
||||
if (state.subId == subId) {
|
||||
@@ -285,9 +314,11 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
|
||||
mIconController.removeAllIconsForSlot(mSlotMobile);
|
||||
mMobileStates.clear();
|
||||
mNoCallingStates.clear();
|
||||
final int n = subs.size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
mMobileStates.add(new MobileIconState(subs.get(i).getSubscriptionId()));
|
||||
mNoCallingStates.add(new NoCallingIconState(subs.get(i).getSubscriptionId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,6 +408,53 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
// Don't care.
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the StatusBar state for no Calling & SMS.
|
||||
*/
|
||||
public static class NoCallingIconState {
|
||||
public boolean visible;
|
||||
public int resId;
|
||||
public int subId;
|
||||
|
||||
private NoCallingIconState(int subId) {
|
||||
this.subId = subId;
|
||||
this.resId = R.drawable.ic_qs_no_calling_sms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
// Skipping reference equality bc this should be more of a value type
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
NoCallingIconState that = (NoCallingIconState) o;
|
||||
return visible == that.visible
|
||||
&& resId == that.resId
|
||||
&& subId == that.subId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(visible, resId, subId);
|
||||
}
|
||||
|
||||
private void copyTo(NoCallingIconState other) {
|
||||
other.visible = visible;
|
||||
other.resId = resId;
|
||||
other.subId = subId;
|
||||
}
|
||||
|
||||
private static List<NoCallingIconState> copyStates(List<NoCallingIconState> inStates) {
|
||||
ArrayList<NoCallingIconState> outStates = new ArrayList<>();
|
||||
for (NoCallingIconState state : inStates) {
|
||||
NoCallingIconState copy = new NoCallingIconState(state.subId);
|
||||
state.copyTo(copy);
|
||||
outStates.add(copy);
|
||||
}
|
||||
return outStates;
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class SignalIconState {
|
||||
public boolean visible;
|
||||
public boolean activityOut;
|
||||
|
||||
@@ -145,6 +145,15 @@ public class CallbackHandler extends Handler implements EmergencyListener, Signa
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoCallingStatus(boolean noCalling, int subId) {
|
||||
post(() -> {
|
||||
for (SignalCallback signalCluster : mSignalCallbacks) {
|
||||
signalCluster.setNoCallingStatus(noCalling, subId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubs(List<SubscriptionInfo> subs) {
|
||||
obtainMessage(MSG_SUBS_CHANGED, subs).sendToTarget();
|
||||
|
||||
@@ -458,9 +458,23 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
mCurrentState.dataSim = mobileStatus.dataSim;
|
||||
mCurrentState.carrierNetworkChangeMode = mobileStatus.carrierNetworkChangeMode;
|
||||
mDataState = mobileStatus.dataState;
|
||||
mServiceState = mobileStatus.serviceState;
|
||||
mSignalStrength = mobileStatus.signalStrength;
|
||||
mTelephonyDisplayInfo = mobileStatus.telephonyDisplayInfo;
|
||||
int lastVoiceState = mServiceState != null ? mServiceState.getState() : -1;
|
||||
mServiceState = mobileStatus.serviceState;
|
||||
int currentVoiceState = mServiceState != null ? mServiceState.getState() : -1;
|
||||
// Only update the no calling Status in the below scenarios
|
||||
// 1. The first valid voice state has been received
|
||||
// 2. The voice state has been changed and either the last or current state is
|
||||
// ServiceState.STATE_IN_SERVICE
|
||||
if (lastVoiceState != currentVoiceState
|
||||
&& (lastVoiceState == -1
|
||||
|| (lastVoiceState == ServiceState.STATE_IN_SERVICE
|
||||
|| currentVoiceState == ServiceState.STATE_IN_SERVICE))) {
|
||||
notifyNoCallingStatusChange(
|
||||
currentVoiceState != ServiceState.STATE_IN_SERVICE,
|
||||
mSubscriptionInfo.getSubscriptionId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,6 +92,13 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
|
||||
*/
|
||||
default void setConnectivityStatus(boolean noDefaultNetwork, boolean noValidatedNetwork,
|
||||
boolean noNetworksAvailable) {}
|
||||
|
||||
/**
|
||||
* Callback for listeners to be able to update the no calling & SMS status
|
||||
* @param noCalling whether the calling and SMS is not working.
|
||||
* @param subId subscription ID for which to update the UI
|
||||
*/
|
||||
default void setNoCallingStatus(boolean noCalling, int subId) {}
|
||||
}
|
||||
|
||||
public interface EmergencyListener {
|
||||
|
||||
@@ -167,6 +167,10 @@ public abstract class SignalController<T extends State, I extends IconGroup> {
|
||||
}
|
||||
}
|
||||
|
||||
protected final void notifyNoCallingStatusChange(boolean noCalling, int subId) {
|
||||
mCallbackHandler.setNoCallingStatus(noCalling, subId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resource if resId is not 0, and an empty string otherwise.
|
||||
*/
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.android.internal.statusbar.StatusBarIcon;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController.IconManager;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.NoCallingIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
|
||||
import java.util.List;
|
||||
@@ -64,6 +65,10 @@ public class FakeStatusBarIconController extends BaseLeakChecker<IconManager>
|
||||
public void setMobileIcons(String slot, List<MobileIconState> states) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoCallingIcons(String slot, List<NoCallingIconState> states) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIconVisibility(String slotTty, boolean b) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user