Merge "Update search bar background drawable for dark mode" into qt-dev
diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml
index fc8cc26..5c918fc 100644
--- a/res/layout/radio_info.xml
+++ b/res/layout/radio_info.xml
@@ -25,6 +25,19 @@
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true">
+ <!-- Phone index -->
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/phone_index_label"
+ style="@style/info_label"
+ />
+
+ <Spinner android:id="@+id/phoneIndex"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ />
+
<!-- IMEI -->
<LinearLayout style="@style/entry_layout">
<TextView android:text="@string/radio_info_imei_label" style="@style/info_label" />
@@ -37,6 +50,18 @@
<TextView android:id="@+id/number" style="@style/info_value" />
</LinearLayout>
+ <!-- Subscription ID -->
+ <LinearLayout style="@style/entry_layout">
+ <TextView android:text="@string/radio_info_subid" style="@style/info_label" />
+ <TextView android:id="@+id/subid" style="@style/info_value" />
+ </LinearLayout>
+
+ <!-- Default data subscription -->
+ <LinearLayout style="@style/entry_layout">
+ <TextView android:text="@string/radio_info_dds" style="@style/info_label" />
+ <TextView android:id="@+id/dds" style="@style/info_value" />
+ </LinearLayout>
+
<!-- IMSI -->
<LinearLayout style="@style/entry_layout">
<TextView android:text="@string/radio_info_imsi_label" style="@style/info_label" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1567c75..9c24dd3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -485,6 +485,10 @@
<string name="proxy_url_title">"PAC URL: "</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
+ <string name="radio_info_subid">Current subId:</string>
+ <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
+ <string name="radio_info_dds">SubId of default data SIM:</string>
+ <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_dl_kbps">DL Bandwidth (kbps):</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_ul_kbps">UL Bandwidth (kbps):</string>
@@ -531,6 +535,8 @@
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_data_network_type_label">Data Network Type:</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
+ <string name="phone_index_label">Select phone index</string>
+ <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_set_perferred_label">Set Preferred Network Type:</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_ping_hostname_v4">Ping Hostname(www.google.com) IPv4:</string>
@@ -2237,6 +2243,8 @@
<string name="wifi_carrier_content">Connect via <xliff:g id="name">%1$s</xliff:g></string>
<string name="wifi_scan_always_turnon_message">To improve location accuracy and for other purposes, <xliff:g id="app_name">%1$s</xliff:g> wants to turn on network scanning, even when Wi-Fi is off.\n\nAllow this for all apps that want to scan?</string>
+ <!-- Message to inform user, an unknown app want to enable network scanning. [CHAR LIMIT=200] -->
+ <string name="wifi_scan_always_turn_on_message_unknown">To improve location accuracy and for other purposes, an unknown app wants to turn on network scanning, even when Wi\u2011Fi is off.\n\nAllow this for all apps that want to scan?</string>
<!-- Message informing the user how to turn off [CHAR LIMIT=200] -->
<string name="wifi_scan_always_turnoff_message">To turn this off, go to Advanced in the overflow menu.</string>
<string name="wifi_scan_always_confirm_allow">Allow</string>
diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java
index 0b7d1be..e0ce1c0 100644
--- a/src/com/android/settings/RadioInfo.java
+++ b/src/com/android/settings/RadioInfo.java
@@ -125,6 +125,7 @@
"Unknown"
};
+ private static String[] mPhoneIndexLabels;
private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
private static final int CELL_INFO_LIST_RATE_MAX = 0;
@@ -160,7 +161,7 @@
60000
};
- private void log(String s) {
+ private static void log(String s) {
Log.d(TAG, s);
}
@@ -171,15 +172,17 @@
private static final int EVENT_QUERY_SMSC_DONE = 1005;
private static final int EVENT_UPDATE_SMSC_DONE = 1006;
- private static final int MENU_ITEM_SELECT_BAND = 0;
- private static final int MENU_ITEM_VIEW_ADN = 1;
- private static final int MENU_ITEM_VIEW_FDN = 2;
- private static final int MENU_ITEM_VIEW_SDN = 3;
- private static final int MENU_ITEM_GET_IMS_STATUS = 4;
- private static final int MENU_ITEM_TOGGLE_DATA = 5;
+ private static final int MENU_ITEM_SELECT_BAND = 0;
+ private static final int MENU_ITEM_VIEW_ADN = 1;
+ private static final int MENU_ITEM_VIEW_FDN = 2;
+ private static final int MENU_ITEM_VIEW_SDN = 3;
+ private static final int MENU_ITEM_GET_IMS_STATUS = 4;
+ private static final int MENU_ITEM_TOGGLE_DATA = 5;
private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
private TextView number;
+ private TextView mSubscriptionId;
+ private TextView mDds;
private TextView mSubscriberId;
private TextView callState;
private TextView operatorName;
@@ -219,12 +222,13 @@
private Switch cbrsDataSwitch;
private Switch dsdsSwitch;
private Spinner preferredNetworkType;
+ private Spinner mSelectPhoneIndex;
private Spinner cellInfoRefreshRateSpinner;
private ConnectivityManager mConnectivityManager;
private TelephonyManager mTelephonyManager;
private ImsManager mImsManager = null;
- private Phone phone = null;
+ private Phone mPhone = null;
private String mPingHostnameResultV4;
private String mPingHostnameResultV6;
@@ -237,6 +241,7 @@
private int mPreferredNetworkTypeResult;
private int mCellInfoRefreshRateIndex;
+ private int mSelectedPhoneIndex;
private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
@@ -251,7 +256,9 @@
}
};
- private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
+ // not final because we need to recreate this object to register on a new subId (b/117555407)
+ private PhoneStateListener mPhoneStateListener = new RadioInfoPhoneStateListener();
+ private class RadioInfoPhoneStateListener extends PhoneStateListener {
@Override
public void onDataConnectionStateChanged(int state) {
updateDataState();
@@ -319,7 +326,7 @@
updatePhysicalChannelConfiguration(configs);
}
- };
+ }
private void updatePhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
StringBuilder sb = new StringBuilder();
@@ -346,6 +353,21 @@
preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
}
+ private void updatePhoneIndex(int phoneIndex, int subId) {
+ // unregister listeners on the old subId
+ unregisterPhoneStateListener();
+ mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
+
+ // update the subId
+ mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
+
+ // update the phoneId
+ mImsManager = ImsManager.getInstance(getApplicationContext(), phoneIndex);
+ mPhone = PhoneFactory.getPhone(phoneIndex);
+
+ updateAllFields();
+ }
+
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@@ -404,15 +426,17 @@
mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
- phone = PhoneFactory.getDefaultPhone();
+ mPhone = PhoneFactory.getDefaultPhone();
- //TODO: Need to update this if the default phoneId changes?
- // Better to have an instance per phone?
mImsManager = ImsManager.getInstance(getApplicationContext(),
SubscriptionManager.getDefaultVoicePhoneId());
+ mPhoneIndexLabels = getPhoneIndexLabels(mTelephonyManager);
+
mDeviceId = (TextView) findViewById(R.id.imei);
number = (TextView) findViewById(R.id.number);
+ mSubscriptionId = (TextView) findViewById(R.id.subid);
+ mDds = (TextView) findViewById(R.id.dds);
mSubscriberId = (TextView) findViewById(R.id.imsi);
callState = (TextView) findViewById(R.id.call);
operatorName = (TextView) findViewById(R.id.operator);
@@ -439,10 +463,17 @@
mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
- ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
+ ArrayAdapter<String> preferredNetworkTypeAdapter = new ArrayAdapter<String> (this,
android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- preferredNetworkType.setAdapter(adapter);
+ preferredNetworkTypeAdapter
+ .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ preferredNetworkType.setAdapter(preferredNetworkTypeAdapter);
+
+ mSelectPhoneIndex = (Spinner) findViewById(R.id.phoneIndex);
+ ArrayAdapter<String> phoneIndexAdapter = new ArrayAdapter<String> (this,
+ android.R.layout.simple_spinner_item, mPhoneIndexLabels);
+ phoneIndexAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mSelectPhoneIndex.setAdapter(phoneIndexAdapter);
cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
@@ -455,7 +486,7 @@
imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
- if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) {
+ if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
imsVolteProvisionedSwitch.setVisibility(View.GONE);
imsVtProvisionedSwitch.setVisibility(View.GONE);
imsWfcProvisionedSwitch.setVisibility(View.GONE);
@@ -513,9 +544,10 @@
mCellInfoRefreshRateIndex = 0; //disabled
mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
+ mSelectedPhoneIndex = 0; //phone 0
//FIXME: Replace with TelephonyManager call
- phone.getPreferredNetworkType(
+ mPhone.getPreferredNetworkType(
mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
restoreFromBundle(icicle);
@@ -527,6 +559,10 @@
log("Started onResume");
+ updateAllFields();
+ }
+
+ private void updateAllFields() {
updateMessageWaiting();
updateCallRedirect();
updateDataState();
@@ -539,6 +575,7 @@
updateLocation(mCellLocationResult);
updateCellInfo(mCellInfoResult);
+ updateSubscriptionIds();
mPingHostnameV4.setText(mPingHostnameResultV4);
mPingHostnameV6.setText(mPingHostnameResultV6);
@@ -552,6 +589,10 @@
preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
+ // set phone index
+ mSelectPhoneIndex.setSelection(mSelectedPhoneIndex, true);
+ mSelectPhoneIndex.setOnItemSelectedListener(mSelectPhoneIndexHandler);
+
radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
@@ -563,19 +604,8 @@
cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener);
}
- mTelephonyManager.listen(mPhoneStateListener,
- PhoneStateListener.LISTEN_CALL_STATE
- //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
- // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
- | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
- | PhoneStateListener.LISTEN_DATA_ACTIVITY
- | PhoneStateListener.LISTEN_CELL_LOCATION
- | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
- | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
- | PhoneStateListener.LISTEN_CELL_INFO
- | PhoneStateListener.LISTEN_SERVICE_STATE
- | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
- | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
+ unregisterPhoneStateListener();
+ registerPhoneStateListener();
mConnectivityManager.registerNetworkCallback(
mDefaultNetworkRequest, mNetworkCallback, mHandler);
@@ -611,6 +641,8 @@
mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
mPreferredNetworkLabels.length - 1);
+ mSelectedPhoneIndex = b.getInt("mSelectedPhoneIndex", 0);
+
mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
}
@@ -621,6 +653,7 @@
outState.putString("mHttpClientTestResult", mHttpClientTestResult);
outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
+ outState.putInt("mSelectedPhoneIndex", mSelectedPhoneIndex);
outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
}
@@ -636,7 +669,7 @@
R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
menu.add(1, MENU_ITEM_VIEW_SDN, 0,
R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
- if (ImsManager.isImsSupportedOnDevice(phone.getContext())) {
+ if (ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
menu.add(1, MENU_ITEM_GET_IMS_STATUS,
0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
}
@@ -668,9 +701,61 @@
return true;
}
+ // returns array of string labels for each phone index. The array index is equal to the phone
+ // index.
+ private static String[] getPhoneIndexLabels(TelephonyManager tm) {
+ int phones = tm.getPhoneCount();
+ String[] labels = new String[phones];
+ for (int i = 0; i < phones; i++) {
+ labels[i] = "Phone " + i;
+ }
+ return labels;
+ }
+
+ private void unregisterPhoneStateListener() {
+ mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
+
+ // clear all fields so they are blank until the next listener event occurs
+ operatorName.setText("");
+ gprsState.setText("");
+ dataNetwork.setText("");
+ voiceNetwork.setText("");
+ sent.setText("");
+ received.setText("");
+ callState.setText("");
+ mLocation.setText("");
+ mMwiValue = false;
+ mMwi.setText("");
+ mCfiValue = false;
+ mCfi.setText("");
+ mCellInfo.setText("");
+ dBm.setText("");
+ gsmState.setText("");
+ roamingState.setText("");
+ mPhyChanConfig.setText("");
+ }
+
+ // register mPhoneStateListener for relevant fields using the current TelephonyManager
+ private void registerPhoneStateListener() {
+ mPhoneStateListener = new RadioInfoPhoneStateListener();
+ mTelephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_CALL_STATE
+ //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
+ // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
+ | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
+ | PhoneStateListener.LISTEN_DATA_ACTIVITY
+ | PhoneStateListener.LISTEN_CELL_LOCATION
+ | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
+ | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
+ | PhoneStateListener.LISTEN_CELL_INFO
+ | PhoneStateListener.LISTEN_SERVICE_STATE
+ | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
+ | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
+ }
+
private void updateDnsCheckState() {
//FIXME: Replace with a TelephonyManager call
- dnsCheckState.setText(phone.isDnsCheckDisabled() ?
+ dnsCheckState.setText(mPhone.isDnsCheckDisabled() ?
"0.0.0.0 allowed" :"0.0.0.0 not allowed");
}
@@ -889,6 +974,11 @@
mCellInfo.setText(buildCellInfoString(arrayCi));
}
+ private final void updateSubscriptionIds() {
+ mSubscriptionId.setText(Integer.toString(mPhone.getSubId()));
+ mDds.setText(Integer.toString(SubscriptionManager.getDefaultDataSubscriptionId()));
+ }
+
private final void
updateMessageWaiting() {
mMwi.setText(String.valueOf(mMwiValue));
@@ -975,12 +1065,12 @@
}
private final void updateNetworkType() {
- if(phone != null) {
- ServiceState ss = phone.getServiceState();
+ if(mPhone != null) {
+ ServiceState ss = mPhone.getServiceState();
dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
- phone.getServiceState().getRilDataRadioTechnology()));
+ mPhone.getServiceState().getRilDataRadioTechnology()));
voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
- phone.getServiceState().getRilVoiceRadioTechnology()));
+ mPhone.getServiceState().getRilVoiceRadioTechnology()));
}
}
@@ -989,16 +1079,16 @@
String s;
Resources r = getResources();
- s = phone.getDeviceId();
+ s = mPhone.getDeviceId();
if (s == null) s = r.getString(R.string.radioInfo_unknown);
mDeviceId.setText(s);
- s = phone.getSubscriberId();
+ s = mPhone.getSubscriberId();
if (s == null) s = r.getString(R.string.radioInfo_unknown);
mSubscriberId.setText(s);
//FIXME: Replace with a TelephonyManager call
- s = phone.getLine1Number();
+ s = mPhone.getLine1Number();
if (s == null) s = r.getString(R.string.radioInfo_unknown);
number.setText(s);
}
@@ -1075,7 +1165,7 @@
private void refreshSmsc() {
//FIXME: Replace with a TelephonyManager call
- phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
+ mPhone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
}
private final void updateAllCellInfo() {
@@ -1147,8 +1237,7 @@
// the content provider, which causes it to be loaded in a process
// other than the Dialer process, which causes a lot of stuff to
// break.
- intent.setClassName("com.android.phone",
- "com.android.phone.SimContacts");
+ intent.setClassName("com.android.phone", "com.android.phone.SimContacts");
startActivity(intent);
return true;
}
@@ -1162,8 +1251,7 @@
// the content provider, which causes it to be loaded in a process
// other than the Dialer process, which causes a lot of stuff to
// break.
- intent.setClassName("com.android.phone",
- "com.android.phone.settings.fdn.FdnList");
+ intent.setClassName("com.android.phone", "com.android.phone.settings.fdn.FdnList");
startActivity(intent);
return true;
}
@@ -1178,8 +1266,7 @@
// the content provider, which causes it to be loaded in a process
// other than the Dialer process, which causes a lot of stuff to
// break.
- intent.setClassName("com.android.phone",
- "com.android.phone.ADNList");
+ intent.setClassName("com.android.phone", "com.android.phone.ADNList");
startActivity(intent);
return true;
}
@@ -1187,11 +1274,11 @@
private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- boolean isImsRegistered = phone.isImsRegistered();
- boolean availableVolte = phone.isVolteEnabled();
- boolean availableWfc = phone.isWifiCallingEnabled();
- boolean availableVt = phone.isVideoEnabled();
- boolean availableUt = phone.isUtEnabled();
+ boolean isImsRegistered = mPhone.isImsRegistered();
+ boolean availableVolte = mPhone.isVolteEnabled();
+ boolean availableWfc = mPhone.isWifiCallingEnabled();
+ boolean availableVt = mPhone.isVideoEnabled();
+ boolean availableUt = mPhone.isUtEnabled();
final String imsRegString = isImsRegistered ?
getString(R.string.radio_info_ims_reg_status_registered) :
@@ -1248,7 +1335,7 @@
private boolean isRadioOn() {
//FIXME: Replace with a TelephonyManager call
- return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
+ return mPhone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
}
private void updateRadioPowerState() {
@@ -1280,7 +1367,7 @@
}
void setImsConfigProvisionedState(int configItem, boolean state) {
- if (phone != null && mImsManager != null) {
+ if (mPhone != null && mImsManager != null) {
QueuedWork.queue(new Runnable() {
public void run() {
try {
@@ -1299,14 +1386,14 @@
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
- phone.setRadioPower(isChecked);
+ mPhone.setRadioPower(isChecked);
}
};
private boolean isImsVolteProvisioned() {
- if (phone != null && mImsManager != null) {
- return mImsManager.isVolteEnabledByPlatform(phone.getContext())
- && mImsManager.isVolteProvisionedOnDevice(phone.getContext());
+ if (mPhone != null && mImsManager != null) {
+ return mImsManager.isVolteEnabledByPlatform(mPhone.getContext())
+ && mImsManager.isVolteProvisionedOnDevice(mPhone.getContext());
}
return false;
}
@@ -1319,9 +1406,9 @@
};
private boolean isImsVtProvisioned() {
- if (phone != null && mImsManager != null) {
- return mImsManager.isVtEnabledByPlatform(phone.getContext())
- && mImsManager.isVtProvisionedOnDevice(phone.getContext());
+ if (mPhone != null && mImsManager != null) {
+ return mImsManager.isVtEnabledByPlatform(mPhone.getContext())
+ && mImsManager.isVtProvisionedOnDevice(mPhone.getContext());
}
return false;
}
@@ -1334,9 +1421,9 @@
};
private boolean isImsWfcProvisioned() {
- if (phone != null && mImsManager != null) {
- return mImsManager.isWfcEnabledByPlatform(phone.getContext())
- && mImsManager.isWfcProvisionedOnDevice(phone.getContext());
+ if (mPhone != null && mImsManager != null) {
+ return mImsManager.isWfcEnabledByPlatform(mPhone.getContext())
+ && mImsManager.isWfcProvisionedOnDevice(mPhone.getContext());
}
return false;
}
@@ -1391,7 +1478,7 @@
}
private void updateImsProvisionedState() {
- if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) {
+ if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
return;
}
log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
@@ -1401,31 +1488,31 @@
imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
imsVolteProvisionedSwitch.setEnabled(!Build.IS_USER
- && mImsManager.isVolteEnabledByPlatform(phone.getContext()));
+ && mImsManager.isVolteEnabledByPlatform(mPhone.getContext()));
imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
imsVtProvisionedSwitch.setEnabled(!Build.IS_USER
- && mImsManager.isVtEnabledByPlatform(phone.getContext()));
+ && mImsManager.isVtEnabledByPlatform(mPhone.getContext()));
imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
imsWfcProvisionedSwitch.setEnabled(!Build.IS_USER
- && mImsManager.isWfcEnabledByPlatform(phone.getContext()));
+ && mImsManager.isWfcEnabledByPlatform(mPhone.getContext()));
eabProvisionedSwitch.setOnCheckedChangeListener(null);
eabProvisionedSwitch.setChecked(isEabProvisioned());
eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
eabProvisionedSwitch.setEnabled(!Build.IS_USER
- && isEabEnabledByPlatform(phone.getContext()));
+ && isEabEnabledByPlatform(mPhone.getContext()));
}
OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
public void onClick(View v) {
//FIXME: Replace with a TelephonyManager call
- phone.disableDnsCheck(!phone.isDnsCheckDisabled());
+ mPhone.disableDnsCheck(!mPhone.isDnsCheckDisabled());
updateDnsCheckState();
}
};
@@ -1452,7 +1539,7 @@
OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
public void onClick(View v) {
updateSmscButton.setEnabled(false);
- phone.setSmscAddress(smsc.getText().toString(),
+ mPhone.setSmscAddress(smsc.getText().toString(),
mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
}
};
@@ -1497,14 +1584,40 @@
// want this setting to be set, so that if the radio hiccups and this setting
// is for some reason unsuccessful, future calls to the radio will reflect
// the users's preference which is set here.
- final int subId = phone.getSubId();
+ final int subId = mPhone.getSubId();
if (SubscriptionManager.isUsableSubIdValue(subId)) {
- Settings.Global.putInt(phone.getContext().getContentResolver(),
+ Settings.Global.putInt(mPhone.getContext().getContentResolver(),
PREFERRED_NETWORK_MODE + subId, mPreferredNetworkTypeResult);
}
log("Calling setPreferredNetworkType(" + mPreferredNetworkTypeResult + ")");
Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
- phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
+ mPhone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
+ }
+ }
+
+ public void onNothingSelected(AdapterView parent) {
+ }
+ };
+
+ AdapterView.OnItemSelectedListener mSelectPhoneIndexHandler =
+ new AdapterView.OnItemSelectedListener() {
+
+ public void onItemSelected(AdapterView parent, View v, int pos, long id) {
+ if (pos >= 0 && pos <= mPhoneIndexLabels.length - 1) {
+ // the array position is equal to the phone index
+ int phoneIndex = pos;
+ Phone[] phones = PhoneFactory.getPhones();
+ if (phones == null || phones.length <= phoneIndex) {
+ return;
+ }
+ // getSubId says it takes a slotIndex, but it actually takes a phone index
+ int[] subIds = SubscriptionManager.getSubId(phoneIndex);
+ if (subIds == null || subIds.length < 1) {
+ return;
+ }
+ mSelectedPhoneIndex = phoneIndex;
+
+ updatePhoneIndex(phoneIndex, subIds[0]);
}
}
diff --git a/src/com/android/settings/SetupWizardUtils.java b/src/com/android/settings/SetupWizardUtils.java
index 7a2fe80..077d94c 100644
--- a/src/com/android/settings/SetupWizardUtils.java
+++ b/src/com/android/settings/SetupWizardUtils.java
@@ -25,11 +25,16 @@
public class SetupWizardUtils {
- public static int getTheme(Intent intent) {
+ public static String getThemeString(Intent intent) {
String theme = intent.getStringExtra(WizardManagerHelper.EXTRA_THEME);
if (theme == null) {
theme = SetupWizardProperties.theme().orElse("");
}
+ return theme;
+ }
+
+ public static int getTheme(Intent intent) {
+ String theme = getThemeString(intent);
// TODO(yukl): Move to ThemeResolver and add any additional required attributes in
// onApplyThemeResource using Theme overlays
if (theme != null) {
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index b4b909d..ba5e73f 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -135,7 +135,7 @@
implements View.OnClickListener, OnItemSelectedListener, SearchView.OnQueryTextListener {
static final String TAG = "ManageApplications";
- static final boolean DEBUG = true;
+ static final boolean DEBUG = false;
// Intent extras.
public static final String EXTRA_CLASSNAME = "classname";
@@ -151,6 +151,7 @@
private static final String EXTRA_HAS_ENTRIES = "hasEntries";
private static final String EXTRA_HAS_BRIDGE = "hasBridge";
private static final String EXTRA_FILTER_TYPE = "filterType";
+ private static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view";
// attributes used as keys when passing values to AppInfoDashboardFragment activity
public static final String APP_CHG = "chg";
@@ -220,6 +221,9 @@
FilterSpinnerAdapter mFilterAdapter;
@VisibleForTesting
RecyclerView mRecyclerView;
+ // Whether or not search view is expanded.
+ @VisibleForTesting
+ boolean mExpandSearch;
private View mRootView;
private Spinner mFilterSpinner;
@@ -307,12 +311,14 @@
mFilter = appFilterRegistry.get(appFilterRegistry.getDefaultFilterType(mListType));
mIsWorkOnly = args != null ? args.getBoolean(EXTRA_WORK_ONLY) : false;
mWorkUserId = args != null ? args.getInt(EXTRA_WORK_ID) : NO_USER_SPECIFIED;
+ mExpandSearch = activity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
if (savedInstanceState != null) {
mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder);
mShowSystem = savedInstanceState.getBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
mFilterType =
savedInstanceState.getInt(EXTRA_FILTER_TYPE, AppFilterRegistry.FILTER_APPS_ALL);
+ mExpandSearch = savedInstanceState.getBoolean(EXTRA_EXPAND_SEARCH_VIEW);
}
mInvalidSizeStr = activity.getText(R.string.invalid_size_value);
@@ -501,6 +507,7 @@
outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
outState.putBoolean(EXTRA_HAS_ENTRIES, mApplications.mHasReceivedLoadEntries);
outState.putBoolean(EXTRA_HAS_BRIDGE, mApplications.mHasReceivedBridgeCallback);
+ outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
outState.putInt(EXTRA_FILTER_TYPE, mFilter.getFilterType());
if (mApplications != null) {
mApplications.onSaveInstanceState(outState);
@@ -607,6 +614,9 @@
mSearchView = (SearchView) searchMenuItem.getActionView();
mSearchView.setQueryHint(getText(R.string.search_settings));
mSearchView.setOnQueryTextListener(this);
+ if (mExpandSearch) {
+ searchMenuItem.expandActionView();
+ }
}
updateOptionsMenu();
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index 81b70b5..a8e4206 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -27,6 +27,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
+import com.android.settings.SetupWizardUtils;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
import com.android.settings.password.ChooseLockSettingsHelper;
@@ -123,6 +124,15 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ Intent intent = getIntent();
+ if (intent.getStringExtra(WizardManagerHelper.EXTRA_THEME) == null) {
+ // Put the theme in the intent so it gets propagated to other activities in the flow
+ intent.putExtra(
+ WizardManagerHelper.EXTRA_THEME,
+ SetupWizardUtils.getThemeString(intent));
+ }
+
mBiometricUnlockDisabledByAdmin = isDisabledByAdmin();
setContentView(getLayoutResource());
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
index bba7f53..bdf863e 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
@@ -16,8 +16,11 @@
package com.android.settings.homepage.contextualcards;
-import java.util.List;
+import androidx.slice.Slice;
/** Feature provider for the contextual card feature. */
public interface ContextualCardFeatureProvider {
+
+ /** Log package when user clicks contextual notification channel card. */
+ void logNotificationPackage(Slice slice);
}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
index 03a1550..4af2838 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
@@ -16,7 +16,22 @@
package com.android.settings.homepage.contextualcards;
+import static android.content.Context.MODE_PRIVATE;
+
import android.content.Context;
+import android.content.SharedPreferences;
+import android.util.ArraySet;
+
+import androidx.slice.Slice;
+import androidx.slice.SliceMetadata;
+import androidx.slice.core.SliceAction;
+
+import com.android.settings.SettingsActivity;
+import com.android.settings.applications.AppInfoBase;
+import com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice;
+import com.android.settings.slices.CustomSliceRegistry;
+
+import java.util.Set;
public class ContextualCardFeatureProviderImpl implements ContextualCardFeatureProvider {
private final Context mContext;
@@ -24,4 +39,27 @@
public ContextualCardFeatureProviderImpl(Context context) {
mContext = context;
}
+
+ @Override
+ public void logNotificationPackage(Slice slice) {
+ if (slice == null || !slice.getUri().equals(
+ CustomSliceRegistry.CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI)) {
+ return;
+ }
+
+ final SliceAction primaryAction = SliceMetadata.from(mContext, slice).getPrimaryAction();
+ final String currentPackage = primaryAction.getAction().getIntent()
+ .getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
+ .getString(AppInfoBase.ARG_PACKAGE_NAME);
+
+ final SharedPreferences prefs = mContext.getSharedPreferences(
+ ContextualNotificationChannelSlice.PREFS, MODE_PRIVATE);
+ final Set<String> interactedPackages = prefs.getStringSet(
+ ContextualNotificationChannelSlice.PREF_KEY_INTERACTED_PACKAGES, new ArraySet<>());
+
+ final Set<String> newInteractedPackages = new ArraySet<>(interactedPackages);
+ newInteractedPackages.add(currentPackage);
+ prefs.edit().putStringSet(ContextualNotificationChannelSlice.PREF_KEY_INTERACTED_PACKAGES,
+ newInteractedPackages).apply();
+ }
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/ContextualNotificationChannelSlice.java b/src/com/android/settings/homepage/contextualcards/slices/ContextualNotificationChannelSlice.java
index 2025a06..17cae77 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/ContextualNotificationChannelSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/ContextualNotificationChannelSlice.java
@@ -16,14 +16,23 @@
package com.android.settings.homepage.contextualcards.slices;
+import static android.content.Context.MODE_PRIVATE;
+
import android.content.Context;
import android.net.Uri;
+import android.util.ArraySet;
import com.android.settings.R;
import com.android.settings.slices.CustomSliceRegistry;
+import com.android.settings.slices.SliceBackgroundWorker;
+
+import java.util.Set;
public class ContextualNotificationChannelSlice extends NotificationChannelSlice {
+ public static final String PREFS = "notification_channel_slice_prefs";
+ public static final String PREF_KEY_INTERACTED_PACKAGES = "interacted_packages";
+
public ContextualNotificationChannelSlice(Context context) {
super(context);
}
@@ -37,4 +46,18 @@
protected CharSequence getSubTitle(String packageName, int uid) {
return mContext.getText(R.string.recently_installed_app);
}
+
+ @Override
+ protected boolean isUserInteracted(String packageName) {
+ // Check the package has been interacted on current slice or not.
+ final Set<String> interactedPackages =
+ mContext.getSharedPreferences(PREFS, MODE_PRIVATE)
+ .getStringSet(PREF_KEY_INTERACTED_PACKAGES, new ArraySet<>());
+ return interactedPackages.contains(packageName);
+ }
+
+ @Override
+ public Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
+ return NotificationChannelWorker.class;
+ }
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
index 0550e7b..e5cee37 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
@@ -218,6 +218,17 @@
.toIntent();
}
+ /**
+ * Check the package has been interacted by user or not.
+ * Will use to filter package in {@link #getRecentlyInstalledPackages()}.
+ *
+ * @param packageName The app package name.
+ * @return true if the package was interacted, false otherwise.
+ */
+ protected boolean isUserInteracted(String packageName) {
+ return false;
+ }
+
@VisibleForTesting
IconCompat getApplicationIcon(String packageName) {
final Drawable drawable;
@@ -328,8 +339,9 @@
final List<PackageInfo> installedPackages =
mContext.getPackageManager().getInstalledPackages(0);
for (PackageInfo packageInfo : installedPackages) {
- // Not include system app.
- if (packageInfo.applicationInfo.isSystemApp()) {
+ // Not include system app and interacted app.
+ if (packageInfo.applicationInfo.isSystemApp()
+ || isUserInteracted(packageInfo.packageName)) {
continue;
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelWorker.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelWorker.java
new file mode 100644
index 0000000..f1d0d59
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelWorker.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2019 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.settings.homepage.contextualcards.slices;
+
+import static android.content.Context.MODE_PRIVATE;
+
+import static com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice.PREFS;
+import static com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice.PREF_KEY_INTERACTED_PACKAGES;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.pm.PackageInfo;
+import android.net.Uri;
+import android.util.ArraySet;
+
+import com.android.settings.slices.SliceBackgroundWorker;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class NotificationChannelWorker extends SliceBackgroundWorker<Void> {
+
+ public NotificationChannelWorker(Context context, Uri uri) {
+ super(context, uri);
+ }
+
+ @Override
+ protected void onSlicePinned() {
+ }
+
+ @Override
+ protected void onSliceUnpinned() {
+ removeUninstalledPackages();
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ private void removeUninstalledPackages() {
+ final SharedPreferences prefs = getContext().getSharedPreferences(PREFS, MODE_PRIVATE);
+ final Set<String> interactedPackages =
+ prefs.getStringSet(PREF_KEY_INTERACTED_PACKAGES, new ArraySet());
+ if (interactedPackages.isEmpty()) {
+ return;
+ }
+
+ final List<PackageInfo> installedPackageInfos =
+ getContext().getPackageManager().getInstalledPackages(0);
+ final List<String> installedPackages = installedPackageInfos.stream()
+ .map(packageInfo -> packageInfo.packageName)
+ .collect(Collectors.toList());
+ final Set<String> newInteractedPackages = new ArraySet<>();
+ for (String packageName : interactedPackages) {
+ if (installedPackages.contains(packageName)) {
+ newInteractedPackages.add(packageName);
+ }
+ }
+ prefs.edit().putStringSet(PREF_KEY_INTERACTED_PACKAGES, newInteractedPackages).apply();
+ }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
index a9a8346..f7b2bf5 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
@@ -27,6 +27,7 @@
import com.android.settings.R;
import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
import com.android.settings.homepage.contextualcards.logging.ContextualCardLogUtils;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -64,6 +65,12 @@
metricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_CONTEXTUAL_CARD_CLICK, log);
+
+ final ContextualCardFeatureProvider contextualCardFeatureProvider =
+ FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(
+ mContext);
+
+ contextualCardFeatureProvider.logNotificationPackage(slice);
});
// Customize slice view for Settings
diff --git a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
index fd57bf5..a334aeb 100644
--- a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
+++ b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
@@ -50,6 +50,7 @@
private List<String> mForbiddenPlmns;
private int mLevel = LEVEL_NONE;
private boolean mShow4GForLTE;
+ private boolean mUseNewApi;
// The following constants are used to draw signal icon.
private static final Drawable EMPTY_DRAWABLE = new ColorDrawable(Color.TRANSPARENT);
@@ -61,6 +62,8 @@
mCellInfo = cellinfo;
mForbiddenPlmns = forbiddenPlmns;
mShow4GForLTE = show4GForLTE;
+ mUseNewApi = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI);
refresh();
}
@@ -114,7 +117,9 @@
}
private void updateIcon(int level) {
- if (level < 0 || level >= NUMBER_OF_LEVELS) return;
+ if (!mUseNewApi || level < 0 || level >= NUMBER_OF_LEVELS) {
+ return;
+ }
Context context = getContext();
SignalDrawable signalDrawable = new SignalDrawable(getContext());
signalDrawable.setLevel(
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index f1391dc..7f71925 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -19,6 +19,7 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
+import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -50,6 +51,7 @@
private PanelContent mPanel;
private MetricsFeatureProvider mMetricsProvider;
+ private String mPanelClosedKey;
@VisibleForTesting
PanelSlicesAdapter mAdapter;
@@ -111,15 +113,26 @@
return view;
}
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+
+ if (TextUtils.isEmpty(mPanelClosedKey)) {
+ mPanelClosedKey = PanelClosedKeys.KEY_OTHERS;
+ }
+
+ mMetricsProvider.action(
+ 0 /* attribution */,
+ SettingsEnums.PAGE_HIDE,
+ mPanel.getMetricsCategory(),
+ mPanelClosedKey,
+ 0 /* value */);
+ }
+
@VisibleForTesting
View.OnClickListener getSeeMoreListener() {
return (v) -> {
- mMetricsProvider.action(
- 0 /* attribution */,
- SettingsEnums.PAGE_HIDE ,
- mPanel.getMetricsCategory(),
- PanelClosedKeys.KEY_SEE_MORE,
- 0 /* value */);
+ mPanelClosedKey = PanelClosedKeys.KEY_SEE_MORE;
final FragmentActivity activity = getActivity();
activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
activity.finish();
@@ -129,12 +142,7 @@
@VisibleForTesting
View.OnClickListener getCloseListener() {
return (v) -> {
- mMetricsProvider.action(
- 0 /* attribution */,
- SettingsEnums.PAGE_HIDE,
- mPanel.getMetricsCategory(),
- PanelClosedKeys.KEY_DONE,
- 0 /* value */);
+ mPanelClosedKey = PanelClosedKeys.KEY_DONE;
getActivity().finish();
};
}
diff --git a/src/com/android/settings/panel/PanelLoggingContract.java b/src/com/android/settings/panel/PanelLoggingContract.java
index e149186..e6e3012 100644
--- a/src/com/android/settings/panel/PanelLoggingContract.java
+++ b/src/com/android/settings/panel/PanelLoggingContract.java
@@ -39,8 +39,9 @@
String KEY_DONE = "done";
/**
- * The user clicked outside the dialog, closing the Panel.
+ * The user closed the panel by other ways, for example: clicked outside of dialog, tapping
+ * on back button, etc.
*/
- String KEY_CLICKED_OUT = "clicked_out";
+ String KEY_OTHERS = "others";
}
}
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index 8aee382..eabd715 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -97,21 +97,4 @@
fragmentManager.beginTransaction().add(R.id.main_content, panelFragment).commit();
}
}
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
- final PanelContent panelContent = FeatureFactory.getFactory(this)
- .getPanelFeatureProvider()
- .getPanel(this, getIntent().getAction(), null /* Media Package Name */);
- FeatureFactory.getFactory(this)
- .getMetricsFeatureProvider()
- .action(0 /* attribution */,
- SettingsEnums.PAGE_HIDE,
- panelContent.getMetricsCategory(),
- PanelClosedKeys.KEY_CLICKED_OUT,
- 0 /* value */);
- }
- return super.onTouchEvent(event);
- }
}
diff --git a/src/com/android/settings/wifi/WifiScanModeActivity.java b/src/com/android/settings/wifi/WifiScanModeActivity.java
index 934e972..5342729 100644
--- a/src/com/android/settings/wifi/WifiScanModeActivity.java
+++ b/src/com/android/settings/wifi/WifiScanModeActivity.java
@@ -25,6 +25,7 @@
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.provider.Settings;
+import android.text.TextUtils;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
@@ -132,7 +133,9 @@
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
- .setMessage(getString(R.string.wifi_scan_always_turnon_message, mApp))
+ .setMessage(TextUtils.isEmpty(mApp) ?
+ getString(R.string.wifi_scan_always_turn_on_message_unknown) :
+ getString(R.string.wifi_scan_always_turnon_message, mApp))
.setPositiveButton(R.string.wifi_scan_always_confirm_allow,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 27c3e7d..58b1408 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -19,17 +19,14 @@
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING;
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE;
-import static com.android.settings.applications.manageapplications.AppFilterRegistry
- .FILTER_APPS_ALL;
-import static com.android.settings.applications.manageapplications.ManageApplications
- .LIST_TYPE_MAIN;
-import static com.android.settings.applications.manageapplications.ManageApplications
- .LIST_TYPE_NOTIFICATION;
+import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_ALL;
+import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MAIN;
+import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION;
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
@@ -172,7 +169,7 @@
when(searchMenu.getActionView()).thenReturn(searchView);
when(mMenu.findItem(R.id.search_app_list_menu)).thenReturn(searchMenu);
when(mMenu.add(anyInt() /* groupId */, anyInt() /* itemId */, anyInt() /* order */,
- anyInt() /* titleRes */)).thenReturn(helpMenu);
+ anyInt() /* titleRes */)).thenReturn(helpMenu);
doReturn("Test").when(mFragment).getText(anyInt() /* resId */);
doNothing().when(mFragment).updateOptionsMenu();
@@ -182,9 +179,27 @@
}
@Test
+ public void onCreateOptionsMenu_hasExpandSearchFlag_shouldExpandSearchView() {
+ final SearchView searchView = mock(SearchView.class);
+ final MenuItem searchMenu = mock(MenuItem.class);
+ final MenuItem helpMenu = mock(MenuItem.class);
+ when(searchMenu.getActionView()).thenReturn(searchView);
+ when(mMenu.findItem(R.id.search_app_list_menu)).thenReturn(searchMenu);
+ when(mMenu.add(anyInt() /* groupId */, anyInt() /* itemId */, anyInt() /* order */,
+ anyInt() /* titleRes */)).thenReturn(helpMenu);
+ doReturn("Test").when(mFragment).getText(anyInt() /* resId */);
+ doNothing().when(mFragment).updateOptionsMenu();
+
+ mFragment.mExpandSearch = true;
+ mFragment.onCreateOptionsMenu(mMenu, mock(MenuInflater.class));
+
+ verify(searchMenu).expandActionView();
+ }
+
+ @Test
public void onQueryTextChange_shouldFilterSearchInApplicationsAdapter() {
final ManageApplications.ApplicationsAdapter adapter =
- mock(ManageApplications.ApplicationsAdapter.class);
+ mock(ManageApplications.ApplicationsAdapter.class);
final String query = "Test App";
ReflectionHelpers.setField(mFragment, "mApplications", adapter);
@@ -289,13 +304,13 @@
when(listContainer.getVisibility()).thenReturn(View.VISIBLE);
ReflectionHelpers.setField(mFragment, "mListContainer", listContainer);
ReflectionHelpers.setField(
- mFragment, "mFilterAdapter", mock(ManageApplications.FilterSpinnerAdapter.class));
+ mFragment, "mFilterAdapter", mock(ManageApplications.FilterSpinnerAdapter.class));
final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
appList.add(mock(ApplicationsState.AppEntry.class));
final ManageApplications.ApplicationsAdapter adapter =
- spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
- AppFilterRegistry.getInstance().get(FILTER_APPS_ALL),
- null /* savedInstanceState */));
+ spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
+ AppFilterRegistry.getInstance().get(FILTER_APPS_ALL),
+ null /* savedInstanceState */));
adapter.onRebuildComplete(appList);
@@ -365,7 +380,7 @@
ReflectionHelpers.setField(holder, "itemView", mock(View.class));
ManageApplications.ApplicationsAdapter adapter =
new ManageApplications.ApplicationsAdapter(mState,
- mFragment, mock(AppFilterItem.class),
+ mFragment, mock(AppFilterItem.class),
mock(Bundle.class));
final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
@@ -399,8 +414,8 @@
@Test
public void applicationsAdapter_filterSearch_emptyQuery_shouldShowFullList() {
final ManageApplications.ApplicationsAdapter adapter =
- new ManageApplications.ApplicationsAdapter(
- mState, mFragment, mock(AppFilterItem.class), Bundle.EMPTY);
+ new ManageApplications.ApplicationsAdapter(
+ mState, mFragment, mock(AppFilterItem.class), Bundle.EMPTY);
final String[] appNames = {"Apricot", "Banana", "Cantaloupe", "Fig", "Mango"};
ReflectionHelpers.setField(adapter, "mOriginalEntries", getTestAppList(appNames));
@@ -412,8 +427,8 @@
@Test
public void applicationsAdapter_filterSearch_noMatch_shouldShowEmptyList() {
final ManageApplications.ApplicationsAdapter adapter =
- new ManageApplications.ApplicationsAdapter(
- mState, mFragment, mock(AppFilterItem.class), Bundle.EMPTY);
+ new ManageApplications.ApplicationsAdapter(
+ mState, mFragment, mock(AppFilterItem.class), Bundle.EMPTY);
final String[] appNames = {"Apricot", "Banana", "Cantaloupe", "Fig", "Mango"};
ReflectionHelpers.setField(adapter, "mOriginalEntries", getTestAppList(appNames));
@@ -425,8 +440,8 @@
@Test
public void applicationsAdapter_filterSearch_shouldShowMatchedItemsOnly() {
final ManageApplications.ApplicationsAdapter adapter =
- new ManageApplications.ApplicationsAdapter(
- mState, mFragment, mock(AppFilterItem.class), Bundle.EMPTY);
+ new ManageApplications.ApplicationsAdapter(
+ mState, mFragment, mock(AppFilterItem.class), Bundle.EMPTY);
final String[] appNames = {"Apricot", "Banana", "Cantaloupe", "Fig", "Mango"};
ReflectionHelpers.setField(adapter, "mOriginalEntries", getTestAppList(appNames));
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImplTest.java
new file mode 100644
index 0000000..e380636
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImplTest.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2019 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.settings.homepage.contextualcards;
+
+import static android.content.Context.MODE_PRIVATE;
+
+import static com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice.PREFS;
+import static com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice.PREF_KEY_INTERACTED_PACKAGES;
+import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI;
+import static com.android.settings.slices.CustomSliceRegistry.FLASHLIGHT_SLICE_URI;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.ArraySet;
+
+import androidx.core.graphics.drawable.IconCompat;
+import androidx.slice.Slice;
+import androidx.slice.SliceProvider;
+import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.SliceAction;
+import androidx.slice.widget.SliceLiveData;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.applications.AppInfoBase;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.Set;
+
+@RunWith(RobolectricTestRunner.class)
+public class ContextualCardFeatureProviderImplTest {
+
+ private Context mContext;
+ private ContextualCardFeatureProviderImpl mImpl;
+ private SharedPreferences mSharedPreferences;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mImpl = new ContextualCardFeatureProviderImpl(mContext);
+ mSharedPreferences = mContext.getSharedPreferences(PREFS, MODE_PRIVATE);
+ // Set-up specs for SliceMetadata.
+ SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+ }
+
+ @After
+ public void tearDown() {
+ removeInteractedPackageFromSharedPreference();
+ }
+
+ @Test
+ public void logNotificationPackage_isContextualNotificationChannel_shouldLogPackage() {
+ final String packageName = "com.android.test.app";
+ final Slice slice = buildSlice(CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI, packageName);
+
+ mImpl.logNotificationPackage(slice);
+
+ final Set<String> interactedPackages = mSharedPreferences.getStringSet(
+ PREF_KEY_INTERACTED_PACKAGES, new ArraySet<>());
+ assertThat(interactedPackages.contains(packageName)).isTrue();
+ }
+
+ @Test
+ public void logNotificationPackage_isNotContextualNotificationChannel_shouldNotLogPackage() {
+ final String packageName = "com.android.test.app";
+ final Slice slice = buildSlice(FLASHLIGHT_SLICE_URI, packageName);
+
+ mImpl.logNotificationPackage(slice);
+
+ final Set<String> interactedPackages = mSharedPreferences.getStringSet(
+ PREF_KEY_INTERACTED_PACKAGES, new ArraySet<>());
+ assertThat(interactedPackages.contains(packageName)).isFalse();
+ }
+
+ private Slice buildSlice(Uri sliceUri, String packageName) {
+ final Bundle args = new Bundle();
+ args.putString(AppInfoBase.ARG_PACKAGE_NAME, packageName);
+ final Intent intent = new Intent("action");
+ intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
+
+ final PendingIntent pendingIntent = spy(
+ PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */));
+ doReturn(intent).when(pendingIntent).getIntent();
+ final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.empty_icon);
+ final SliceAction action = SliceAction.createDeeplink(pendingIntent, icon,
+ ListBuilder.SMALL_IMAGE, "title");
+
+ return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
+ .addRow(new ListBuilder.RowBuilder()
+ .addEndItem(icon, ListBuilder.ICON_IMAGE)
+ .setTitle("title")
+ .setPrimaryAction(action))
+ .build();
+ }
+
+ private void removeInteractedPackageFromSharedPreference() {
+ if (mSharedPreferences.contains(PREF_KEY_INTERACTED_PACKAGES)) {
+ mSharedPreferences.edit().remove(PREF_KEY_INTERACTED_PACKAGES).apply();
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/ContextualNotificationChannelSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/ContextualNotificationChannelSliceTest.java
index f2b87be..8541a30 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/ContextualNotificationChannelSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/ContextualNotificationChannelSliceTest.java
@@ -16,30 +16,49 @@
package com.android.settings.homepage.contextualcards.slices;
+import static android.content.Context.MODE_PRIVATE;
+
+import static com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice.PREFS;
+import static com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice.PREF_KEY_INTERACTED_PACKAGES;
+
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
+import android.content.SharedPreferences;
import android.net.Uri;
+import android.util.ArraySet;
import com.android.settings.R;
import com.android.settings.slices.CustomSliceRegistry;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.Set;
+
@RunWith(RobolectricTestRunner.class)
public class ContextualNotificationChannelSliceTest {
+ private static final String PACKAGE_NAME = "package_name";
+
private Context mContext;
private ContextualNotificationChannelSlice mNotificationChannelSlice;
+ private SharedPreferences mSharedPreferences;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mNotificationChannelSlice = new ContextualNotificationChannelSlice(mContext);
+ mSharedPreferences = mContext.getSharedPreferences(PREFS, MODE_PRIVATE);
+ }
+
+ @After
+ public void tearDown() {
+ removeInteractedPackageFromSharedPreference();
}
@Test
@@ -55,4 +74,34 @@
assertThat(subTitle).isEqualTo(mContext.getText(R.string.recently_installed_app));
}
+
+ @Test
+ public void isUserInteracted_hasInteractedPackage_shouldBeTrue() {
+ addInteractedPackageToSharedPreference();
+
+ final boolean isInteracted = mNotificationChannelSlice.isUserInteracted(PACKAGE_NAME);
+
+ assertThat(isInteracted).isTrue();
+ }
+
+ @Test
+ public void isUserInteracted_noInteractedPackage_shouldBeFalse() {
+ final boolean isInteracted = mNotificationChannelSlice.isUserInteracted(PACKAGE_NAME);
+
+ assertThat(isInteracted).isFalse();
+ }
+
+ private void addInteractedPackageToSharedPreference() {
+ final Set<String> interactedPackages = new ArraySet<>();
+ interactedPackages.add(PACKAGE_NAME);
+
+ mSharedPreferences.edit().putStringSet(PREF_KEY_INTERACTED_PACKAGES,
+ interactedPackages).apply();
+ }
+
+ private void removeInteractedPackageFromSharedPreference() {
+ if (mSharedPreferences.contains(PREF_KEY_INTERACTED_PACKAGES)) {
+ mSharedPreferences.edit().remove(PREF_KEY_INTERACTED_PACKAGES).apply();
+ }
+ }
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
index 12513f6..81f5797 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
@@ -26,7 +26,6 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import android.app.NotificationChannel;
@@ -299,6 +298,21 @@
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.no_suggested_app));
}
+ @Test
+ @Config(shadows = ShadowRestrictedLockUtilsInternal.class)
+ public void getSlice_isInteractedPackage_shouldHaveNoSuggestedAppTitle() {
+ addMockPackageToPackageManager(true /* isRecentlyInstalled */,
+ ApplicationInfo.FLAG_INSTALLED);
+ mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+ false /* isChannelBlocked */);
+ doReturn(true).when(mNotificationChannelSlice).isUserInteracted(any(String.class));
+
+ final Slice slice = mNotificationChannelSlice.getSlice();
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.no_suggested_app));
+ }
+
private void addMockPackageToPackageManager(boolean isRecentlyInstalled, int flags) {
final ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.name = APP_LABEL;
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelWorkerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelWorkerTest.java
new file mode 100644
index 0000000..6ac8b70
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelWorkerTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2019 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.settings.homepage.contextualcards.slices;
+
+import static android.content.Context.MODE_PRIVATE;
+
+import static com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice.PREFS;
+import static com.android.settings.homepage.contextualcards.slices.ContextualNotificationChannelSlice.PREF_KEY_INTERACTED_PACKAGES;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.Shadows.shadowOf;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.pm.PackageInfo;
+import android.net.Uri;
+import android.util.ArraySet;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowPackageManager;
+
+import java.util.Set;
+
+@RunWith(RobolectricTestRunner.class)
+public class NotificationChannelWorkerTest {
+ private static final Uri URI = Uri.parse("content://com.android.settings.slices/test");
+ private static final String PACKAGE_NAME = "com.test.notification.channel.slice";
+
+ private Context mContext;
+ private NotificationChannelWorker mNotificationChannelWorker;
+ private ShadowPackageManager mPackageManager;
+ private SharedPreferences mSharedPreferences;
+
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mNotificationChannelWorker = new NotificationChannelWorker(mContext, URI);
+
+ // Shadow PackageManager to add mock package.
+ mPackageManager = shadowOf(mContext.getPackageManager());
+
+ mSharedPreferences = mContext.getSharedPreferences(PREFS, MODE_PRIVATE);
+ addInteractedPackageToSharedPreference();
+ }
+
+ @After
+ public void tearDown() {
+ mPackageManager.removePackage(PACKAGE_NAME);
+ removeInteractedPackageFromSharedPreference();
+ }
+
+ @Test
+ public void onSliceUnpinned_interactedPackageIsUninstalled_shouldRemovePackage() {
+ mNotificationChannelWorker.onSliceUnpinned();
+
+ final Set<String> interactedPackages = mSharedPreferences.getStringSet(
+ PREF_KEY_INTERACTED_PACKAGES, new ArraySet<>());
+ assertThat(interactedPackages.contains(PACKAGE_NAME)).isFalse();
+ }
+
+ @Test
+ public void onSliceUnpinned_interactedPackageIsInstalled_shouldKeepPackage() {
+ mockInteractedPackageAsInstalled();
+
+ mNotificationChannelWorker.onSliceUnpinned();
+
+ final Set<String> interactedPackages = mSharedPreferences.getStringSet(
+ PREF_KEY_INTERACTED_PACKAGES, new ArraySet<>());
+ assertThat(interactedPackages.contains(PACKAGE_NAME)).isTrue();
+ }
+
+ private void mockInteractedPackageAsInstalled() {
+ final PackageInfo packageInfo = new PackageInfo();
+ packageInfo.packageName = PACKAGE_NAME;
+ mPackageManager.addPackage(packageInfo);
+ }
+
+ private void addInteractedPackageToSharedPreference() {
+ final Set<String> interactedPackages = new ArraySet<>();
+ interactedPackages.add(PACKAGE_NAME);
+
+ mSharedPreferences.edit().putStringSet(PREF_KEY_INTERACTED_PACKAGES,
+ interactedPackages).apply();
+ }
+
+ private void removeInteractedPackageFromSharedPreference() {
+ if (mSharedPreferences.contains(PREF_KEY_INTERACTED_PACKAGES)) {
+ mSharedPreferences.edit().remove(PREF_KEY_INTERACTED_PACKAGES).apply();
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/NetworkOperatorPreferenceTest.java b/tests/robotests/src/com/android/settings/network/telephony/NetworkOperatorPreferenceTest.java
new file mode 100644
index 0000000..704dd95
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/telephony/NetworkOperatorPreferenceTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2019 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.settings.network.telephony;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.telephony.CellInfo;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.ArrayList;
+
+@RunWith(RobolectricTestRunner.class)
+public class NetworkOperatorPreferenceTest {
+ private static final int LEVEL = 2;
+
+ @Mock
+ private Resources mResources;
+ @Mock
+ private CellInfo mCellInfo;
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = spy(RuntimeEnvironment.application);
+ when(mContext.getResources()).thenReturn(mResources);
+ }
+
+ @Test
+ public void setIcon_useOldApi_doNothing() {
+ when(mResources.getBoolean(com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI))
+ .thenReturn(false);
+ final NetworkOperatorPreference preference = spy(
+ new NetworkOperatorPreference(mCellInfo, mContext,
+ new ArrayList<>() /* forbiddenPlmns */, false /* show4GForLTE */));
+
+ preference.setIcon(LEVEL);
+
+ verify(preference, never()).setIcon(any(Drawable.class));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
index be8d8bc..d606ac7 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
@@ -100,6 +100,16 @@
}
@Test
+ public void onDestroy_logCloseEvent() {
+ mPanelFragment.onDestroy();
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_VISIBLE,
+ mFakePanelContent.getMetricsCategory(),
+ any(String.class),
+ 0); }
+
+ @Test
public void panelSeeMoreClick_logsCloseEvent() {
final View.OnClickListener listener = mPanelFragment.getSeeMoreListener();
diff --git a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
index 1d5c3c2..fa15aa0 100644
--- a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
+++ b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
@@ -99,7 +99,7 @@
0,
SettingsEnums.PAGE_HIDE,
SettingsEnums.TESTING,
- PanelLoggingContract.PanelClosedKeys.KEY_CLICKED_OUT,
+ PanelLoggingContract.PanelClosedKeys.KEY_OTHERS,
0
);
}