Snap for 5070519 from f7a0266dcf to qt-release
Change-Id: I97f77aac893254e0aa153ee7ce01cead3d67676b
This commit is contained in:
@@ -36,8 +36,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/restricted_lock_icon_remote_input"
|
||||
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||
android:layout_height="@*android:dimen/config_restricted_icon_size"
|
||||
android:layout_width="@*android:dimen/config_restrictedIconSize"
|
||||
android:layout_height="@*android:dimen/config_restrictedIconSize"
|
||||
android:tint="?android:attr/colorAccent"
|
||||
android:src="@*android:drawable/ic_info"
|
||||
android:layout_marginEnd="?android:attr/dialogPreferredPadding"
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
android:ellipsize="marquee" />
|
||||
<ImageView
|
||||
android:id="@+id/restricted_lock_icon"
|
||||
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||
android:layout_height="@*android:dimen/config_restricted_icon_size"
|
||||
android:layout_width="@*android:dimen/config_restrictedIconSize"
|
||||
android:layout_height="@*android:dimen/config_restrictedIconSize"
|
||||
android:tint="?android:attr/colorAccent"
|
||||
android:src="@*android:drawable/ic_info"
|
||||
android:layout_marginLeft="@dimen/restricted_icon_padding"
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
android:layout_alignParentLeft="true" />
|
||||
<ImageView
|
||||
android:id="@+id/restricted_icon"
|
||||
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||
android:layout_height="@*android:dimen/config_restricted_icon_size"
|
||||
android:layout_width="@*android:dimen/config_restrictedIconSize"
|
||||
android:layout_height="@*android:dimen/config_restrictedIconSize"
|
||||
android:scaleType="centerInside"
|
||||
android:tint="?android:attr/colorAccent"
|
||||
android:src="@*android:drawable/ic_info"
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
android:ellipsize="marquee" />
|
||||
<ImageView
|
||||
android:id="@+id/restricted_icon"
|
||||
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||
android:layout_width="@*android:dimen/config_restrictedIconSize"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerInside"
|
||||
android:tint="?android:attr/colorAccent"
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
||||
android:ellipsize="marquee" />
|
||||
<ImageView android:id="@+id/restricted_icon"
|
||||
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||
android:layout_height="@*android:dimen/config_restricted_icon_size"
|
||||
android:layout_width="@*android:dimen/config_restrictedIconSize"
|
||||
android:layout_height="@*android:dimen/config_restrictedIconSize"
|
||||
android:tint="?android:attr/colorAccent"
|
||||
android:src="@*android:drawable/ic_info"
|
||||
android:baselineAlignBottom="true"
|
||||
|
||||
@@ -267,7 +267,7 @@
|
||||
<!-- Restricted icon in switch bar -->
|
||||
<dimen name="restricted_icon_margin_end">16dp</dimen>
|
||||
<!-- Restricted icon size in switch bar -->
|
||||
<dimen name="restricted_icon_size">@*android:dimen/config_restricted_icon_size</dimen>
|
||||
<dimen name="restricted_icon_size">@*android:dimen/config_restrictedIconSize</dimen>
|
||||
|
||||
<!-- Display Size and Font Size preview screen -->
|
||||
<dimen name="preview_pager_padding">8dp</dimen>
|
||||
|
||||
@@ -2768,6 +2768,10 @@
|
||||
<string name="sim_change_succeeded">SIM PIN changed successfully</string>
|
||||
<!-- SIM card lock settings screen, toast after not entering correct SIM PIN [CHAR LIMIT=40] -->
|
||||
<string name="sim_lock_failed">Can\u2019t change SIM card lock state.\nPossibly incorrect PIN.</string>
|
||||
<!-- SIM card lock settings screen, toast after disabling PIN failed from modem -->
|
||||
<string name="sim_pin_disable_failed">Can\'t disable PIN.</string>
|
||||
<!-- SIM card lock settings screen, toast after enabling PIN failed from modem -->
|
||||
<string name="sim_pin_enable_failed">Can\'t enable PIN.</string>
|
||||
<!-- SIM card lock settings screen, SIM PIN dialog button labels: [CHAR LIMIT=40] -->
|
||||
<string name="sim_enter_ok">OK</string>
|
||||
<!-- SIM card lock settings screen, SIM PIN dialog button labels: [CHAR LIMIT=40] -->
|
||||
|
||||
@@ -17,14 +17,6 @@
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<com.android.settings.network.telephony.CdmaSystemSelectListPreference
|
||||
android:key="cdma_system_select_key"
|
||||
android:title="@string/cdma_system_select_title"
|
||||
android:summary="@string/cdma_system_select_summary"
|
||||
android:entries="@array/cdma_system_select_choices"
|
||||
android:entryValues="@array/cdma_system_select_values"
|
||||
android:dialogTitle="@string/cdma_system_select_dialogtitle" />
|
||||
|
||||
<com.android.settings.network.telephony.CdmaSubscriptionListPreference
|
||||
android:key="cdma_subscription_key"
|
||||
android:title="@string/cdma_subscription_title"
|
||||
|
||||
@@ -91,4 +91,13 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<ListPreference
|
||||
android:key="cdma_system_select_key"
|
||||
android:title="@string/cdma_system_select_title"
|
||||
android:summary="@string/cdma_system_select_summary"
|
||||
android:entries="@array/cdma_system_select_choices"
|
||||
android:entryValues="@array/cdma_system_select_values"
|
||||
android:dialogTitle="@string/cdma_system_select_dialogtitle"
|
||||
settings:controller="com.android.settings.network.telephony.cdma.CdmaSystemSelectPreferenceController"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -46,6 +46,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.telephony.CommandException;
|
||||
import com.android.internal.telephony.Phone;
|
||||
import com.android.internal.telephony.PhoneFactory;
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
@@ -123,7 +124,7 @@ public class IccLockSettings extends SettingsPreferenceFragment
|
||||
AsyncResult ar = (AsyncResult) msg.obj;
|
||||
switch (msg.what) {
|
||||
case MSG_ENABLE_ICC_PIN_COMPLETE:
|
||||
iccLockChanged(ar.exception == null, msg.arg1);
|
||||
iccLockChanged(ar.exception == null, msg.arg1, ar.exception);
|
||||
break;
|
||||
case MSG_CHANGE_ICC_PIN_COMPLETE:
|
||||
iccPinChanged(ar.exception == null, msg.arg1);
|
||||
@@ -453,12 +454,25 @@ public class IccLockSettings extends SettingsPreferenceFragment
|
||||
mPinToggle.setEnabled(false);
|
||||
}
|
||||
|
||||
private void iccLockChanged(boolean success, int attemptsRemaining) {
|
||||
private void iccLockChanged(boolean success, int attemptsRemaining, Throwable exception) {
|
||||
if (success) {
|
||||
mPinToggle.setChecked(mToState);
|
||||
} else {
|
||||
Toast.makeText(getContext(), getPinPasswordErrorMessage(attemptsRemaining),
|
||||
Toast.LENGTH_LONG).show();
|
||||
if (exception instanceof CommandException) {
|
||||
CommandException.Error err = ((CommandException)(exception)).getCommandError();
|
||||
if (err == CommandException.Error.PASSWORD_INCORRECT) {
|
||||
Toast.makeText(getContext(), getPinPasswordErrorMessage(attemptsRemaining),
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
if (mToState) {
|
||||
Toast.makeText(getContext(), mRes.getString
|
||||
(R.string.sim_pin_enable_failed), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(getContext(), mRes.getString
|
||||
(R.string.sim_pin_disable_failed), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mPinToggle.setEnabled(true);
|
||||
resetDialogState();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.app.Activity;
|
||||
@@ -72,7 +72,7 @@ public class AccessibilityServiceWarning {
|
||||
|
||||
Window window = ad.getWindow();
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.privateFlags |= PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
params.privateFlags |= SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
window.setAttributes(params);
|
||||
ad.create();
|
||||
ad.getButton(AlertDialog.BUTTON_POSITIVE).setOnTouchListener(filterTouchListener);
|
||||
|
||||
@@ -30,7 +30,8 @@ public class DefaultBrowserShortcutPreferenceController
|
||||
|
||||
@Override
|
||||
protected boolean hasAppCapability() {
|
||||
return DefaultBrowserPreferenceController.hasBrowserPreference(mPackageName, mContext);
|
||||
return DefaultBrowserPreferenceController
|
||||
.hasBrowserPreference(mPackageName, mContext, UserHandle.myUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.android.settings.applications.appinfo;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
@@ -83,7 +83,7 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getActivity().getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
getActivity().getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +91,7 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
||||
super.onPause();
|
||||
Window window = getActivity().getWindow();
|
||||
WindowManager.LayoutParams attrs = window.getAttributes();
|
||||
attrs.privateFlags &= ~PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
window.setAttributes(attrs);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class DefaultBrowserPicker extends DefaultAppPickerFragment {
|
||||
|
||||
for (ResolveInfo info : list) {
|
||||
try {
|
||||
candidates.add(new DefaultAppInfo(context, mPm,
|
||||
candidates.add(new DefaultAppInfo(context, mPm, mUserId,
|
||||
mPm.getApplicationInfoAsUser(info.activityInfo.packageName, 0, mUserId)));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// Skip unknown packages.
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.util.ArraySet;
|
||||
import android.util.IconDrawableFactory;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settingslib.applications.DefaultAppInfo;
|
||||
@@ -75,8 +76,8 @@ public class DefaultBrowserPreferenceController extends DefaultAppPreferenceCont
|
||||
try {
|
||||
final String packageName = mPackageManager.getDefaultBrowserPackageNameAsUser(mUserId);
|
||||
Log.d(TAG, "Get default browser package: " + packageName);
|
||||
return new DefaultAppInfo(mContext, mPackageManager,
|
||||
mPackageManager.getApplicationInfo(packageName, 0));
|
||||
return new DefaultAppInfo(mContext, mPackageManager, mUserId,
|
||||
mPackageManager.getApplicationInfoAsUser(packageName, 0, mUserId));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -143,7 +144,8 @@ public class DefaultBrowserPreferenceController extends DefaultAppPreferenceCont
|
||||
return null;
|
||||
}
|
||||
|
||||
private Drawable getOnlyAppIcon() {
|
||||
@VisibleForTesting
|
||||
Drawable getOnlyAppIcon() {
|
||||
final List<ResolveInfo> list = getCandidates(mPackageManager, mUserId);
|
||||
if (list != null && list.size() == 1) {
|
||||
final ResolveInfo info = list.get(0);
|
||||
@@ -154,7 +156,7 @@ public class DefaultBrowserPreferenceController extends DefaultAppPreferenceCont
|
||||
}
|
||||
final ApplicationInfo appInfo;
|
||||
try {
|
||||
appInfo = mPackageManager.getApplicationInfo(packageName, 0);
|
||||
appInfo = mPackageManager.getApplicationInfoAsUser(packageName, 0, mUserId);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.w(TAG, "Error getting app info for " + packageName);
|
||||
return null;
|
||||
@@ -169,11 +171,11 @@ public class DefaultBrowserPreferenceController extends DefaultAppPreferenceCont
|
||||
/**
|
||||
* Whether or not the pkg contains browser capability
|
||||
*/
|
||||
public static boolean hasBrowserPreference(String pkg, Context context) {
|
||||
public static boolean hasBrowserPreference(String pkg, Context context, int userId) {
|
||||
final Intent intent = new Intent(BROWSE_PROBE);
|
||||
intent.setPackage(pkg);
|
||||
final List<ResolveInfo> resolveInfos =
|
||||
context.getPackageManager().queryIntentActivities(intent, 0);
|
||||
final List<ResolveInfo> resolveInfos = context.getPackageManager()
|
||||
.queryIntentActivitiesAsUser(intent, 0 /* flags */, userId);
|
||||
return resolveInfos != null && resolveInfos.size() != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DefaultEmergencyPicker extends DefaultAppPickerFragment {
|
||||
final PackageInfo packageInfo =
|
||||
mPm.getPackageInfo(info.activityInfo.packageName, 0);
|
||||
final ApplicationInfo appInfo = packageInfo.applicationInfo;
|
||||
candidates.add(new DefaultAppInfo(context, mPm, appInfo));
|
||||
candidates.add(new DefaultAppInfo(context, mPm, mUserId, appInfo));
|
||||
// Get earliest installed system app.
|
||||
if (isSystemApp(appInfo) && (bestMatch == null ||
|
||||
bestMatch.firstInstallTime > packageInfo.firstInstallTime)) {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DefaultPhonePicker extends DefaultAppPickerFragment {
|
||||
final Context context = getContext();
|
||||
for (String packageName : dialerPackages) {
|
||||
try {
|
||||
candidates.add(new DefaultAppInfo(context, mPm,
|
||||
candidates.add(new DefaultAppInfo(context, mPm, mUserId,
|
||||
mPm.getApplicationInfoAsUser(packageName, 0, mUserId)));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// Skip unknown packages.
|
||||
|
||||
@@ -59,7 +59,8 @@ public class DefaultPhonePreferenceController extends DefaultAppPreferenceContro
|
||||
@Override
|
||||
protected DefaultAppInfo getDefaultAppInfo() {
|
||||
try {
|
||||
return new DefaultAppInfo(mContext, mPackageManager, mPackageManager.getApplicationInfo(
|
||||
return new DefaultAppInfo(mContext, mPackageManager, mUserId,
|
||||
mPackageManager.getApplicationInfo(
|
||||
DefaultDialerManager.getDefaultDialerApplication(mContext, mUserId), 0));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return null;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class DefaultSmsPicker extends DefaultAppPickerFragment {
|
||||
|
||||
for (SmsApplication.SmsApplicationData smsApplicationData : smsApplications) {
|
||||
try {
|
||||
candidates.add(new DefaultAppInfo(context, mPm,
|
||||
candidates.add(new DefaultAppInfo(context, mPm, mUserId,
|
||||
mPm.getApplicationInfoAsUser(smsApplicationData.mPackageName, 0, mUserId)));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// Skip unknown packages.
|
||||
|
||||
@@ -261,10 +261,12 @@ public abstract class DeviceListPreferenceFragment extends
|
||||
cacheRemoveAllPrefs(preferenceGroup);
|
||||
preferenceGroup.setTitle(titleId);
|
||||
mDeviceListGroup = preferenceGroup;
|
||||
setFilter(filter);
|
||||
if (addCachedDevices) {
|
||||
// Don't show bonded devices when screen turned back on
|
||||
setFilter(BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER);
|
||||
addCachedDevices();
|
||||
}
|
||||
setFilter(filter);
|
||||
preferenceGroup.setEnabled(true);
|
||||
removeCachedPrefs(preferenceGroup);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.settings.development;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -66,7 +67,7 @@ public class WebViewAppPreferenceController extends DeveloperOptionsPreferenceCo
|
||||
@VisibleForTesting
|
||||
DefaultAppInfo getDefaultAppInfo() {
|
||||
final PackageInfo currentPackage = mWebViewUpdateServiceWrapper.getCurrentWebViewPackage();
|
||||
return new DefaultAppInfo(mContext, mPackageManager,
|
||||
return new DefaultAppInfo(mContext, mPackageManager, UserHandle.myUserId(),
|
||||
currentPackage == null ? null : currentPackage.applicationInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ public class CdmaOptions {
|
||||
private static final String LOG_TAG = "CdmaOptions";
|
||||
|
||||
private CarrierConfigManager mCarrierConfigManager;
|
||||
private CdmaSystemSelectListPreference mButtonCdmaSystemSelect;
|
||||
private CdmaSubscriptionListPreference mButtonCdmaSubscription;
|
||||
private RestrictedPreference mButtonAPNExpand;
|
||||
private Preference mCategoryAPNExpand;
|
||||
@@ -66,8 +65,6 @@ public class CdmaOptions {
|
||||
mCarrierConfigManager = new CarrierConfigManager(prefFragment.getContext());
|
||||
|
||||
// Initialize preferences.
|
||||
mButtonCdmaSystemSelect = (CdmaSystemSelectListPreference) mPrefScreen
|
||||
.findPreference(BUTTON_CDMA_SYSTEM_SELECT_KEY);
|
||||
mButtonCdmaSubscription = (CdmaSubscriptionListPreference) mPrefScreen
|
||||
.findPreference(BUTTON_CDMA_SUBSCRIPTION_KEY);
|
||||
mButtonCarrierSettings = mPrefScreen.findPreference(BUTTON_CARRIER_SETTINGS_KEY);
|
||||
@@ -91,9 +88,6 @@ public class CdmaOptions {
|
||||
boolean addCarrierSettings =
|
||||
carrierConfig.getBoolean(CarrierConfigManager.KEY_CARRIER_SETTINGS_ENABLE_BOOL);
|
||||
|
||||
mPrefScreen.addPreference(mButtonCdmaSystemSelect);
|
||||
mButtonCdmaSystemSelect.setEnabled(true);
|
||||
|
||||
// Making no assumptions of whether they are added or removed at this point.
|
||||
// Calling add or remove explicitly to make sure they are updated.
|
||||
|
||||
@@ -191,9 +185,7 @@ public class CdmaOptions {
|
||||
}
|
||||
|
||||
public void showDialog(Preference preference) {
|
||||
if (preference.getKey().equals(BUTTON_CDMA_SYSTEM_SELECT_KEY)) {
|
||||
mButtonCdmaSystemSelect.showDialog(null);
|
||||
} else if (preference.getKey().equals(BUTTON_CDMA_SUBSCRIPTION_KEY)) {
|
||||
if (preference.getKey().equals(BUTTON_CDMA_SUBSCRIPTION_KEY)) {
|
||||
mButtonCdmaSubscription.showDialog(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
|
||||
public class CdmaSystemSelectListPreference extends ListPreference {
|
||||
|
||||
private static final String LOG_TAG = "CdmaRoamingListPref";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private MyHandler mHandler = new MyHandler();
|
||||
|
||||
public CdmaSystemSelectListPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
mHandler = new MyHandler();
|
||||
mTelephonyManager = TelephonyManager.from(context);
|
||||
}
|
||||
|
||||
public CdmaSystemSelectListPreference(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subscription id associated with this preference.
|
||||
*
|
||||
* @param subId the subscription id.
|
||||
*/
|
||||
public void setSubscriptionId(int subId) {
|
||||
mTelephonyManager = TelephonyManager.from(getContext()).createForSubscriptionId(subId);
|
||||
queryCdmaRoamingMode();
|
||||
}
|
||||
|
||||
//TODO(b/114749736): Move this to preference controller
|
||||
protected void showDialog(Bundle state) {
|
||||
if (!mTelephonyManager.getEmergencyCallbackMode()) {
|
||||
// show Dialog
|
||||
}
|
||||
}
|
||||
|
||||
//TODO(b/114749736): Move this to preference controller
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
if (positiveResult && (getValue() != null)) {
|
||||
int buttonCdmaRoamingMode = Integer.parseInt(getValue());
|
||||
int settingsCdmaRoamingMode = Settings.Global.getInt(
|
||||
getContext().getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
TelephonyManager.CDMA_ROAMING_MODE_HOME);
|
||||
if (buttonCdmaRoamingMode != settingsCdmaRoamingMode) {
|
||||
int cdmaRoamingMode = TelephonyManager.CDMA_ROAMING_MODE_ANY;
|
||||
if (buttonCdmaRoamingMode != TelephonyManager.CDMA_ROAMING_MODE_ANY) {
|
||||
cdmaRoamingMode = TelephonyManager.CDMA_ROAMING_MODE_HOME;
|
||||
}
|
||||
//Set the Settings.Secure network mode
|
||||
Settings.Global.putInt(
|
||||
getContext().getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
buttonCdmaRoamingMode);
|
||||
//Set the roaming preference mode
|
||||
setCdmaRoamingMode(cdmaRoamingMode);
|
||||
}
|
||||
} else {
|
||||
Log.d(LOG_TAG, String.format("onDialogClosed: positiveResult=%b value=%s -- do nothing",
|
||||
positiveResult, getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
private class MyHandler extends Handler {
|
||||
|
||||
static final int MESSAGE_GET_ROAMING_PREFERENCE = 0;
|
||||
static final int MESSAGE_SET_ROAMING_PREFERENCE = 1;
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MESSAGE_GET_ROAMING_PREFERENCE:
|
||||
handleQueryCdmaRoamingPreference(msg);
|
||||
break;
|
||||
|
||||
case MESSAGE_SET_ROAMING_PREFERENCE:
|
||||
handleSetCdmaRoamingPreference(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleQueryCdmaRoamingPreference(Message msg) {
|
||||
int cdmaRoamingMode = msg.arg1;
|
||||
|
||||
if (cdmaRoamingMode != TelephonyManager.CDMA_ROAMING_MODE_RADIO_DEFAULT) {
|
||||
int settingsRoamingMode = Settings.Global.getInt(
|
||||
getContext().getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
TelephonyManager.CDMA_ROAMING_MODE_HOME);
|
||||
|
||||
//check that statusCdmaRoamingMode is from an accepted value
|
||||
if (cdmaRoamingMode == TelephonyManager.CDMA_ROAMING_MODE_HOME
|
||||
|| cdmaRoamingMode == TelephonyManager.CDMA_ROAMING_MODE_ANY) {
|
||||
//check changes in statusCdmaRoamingMode and updates settingsRoamingMode
|
||||
if (cdmaRoamingMode != settingsRoamingMode) {
|
||||
settingsRoamingMode = cdmaRoamingMode;
|
||||
//changes the Settings.Secure accordingly to statusCdmaRoamingMode
|
||||
Settings.Global.putInt(
|
||||
getContext().getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
settingsRoamingMode);
|
||||
}
|
||||
//changes the mButtonPreferredNetworkMode accordingly to modemNetworkMode
|
||||
setValue(Integer.toString(cdmaRoamingMode));
|
||||
}
|
||||
else {
|
||||
if(DBG) Log.i(LOG_TAG, "reset cdma roaming mode to default" );
|
||||
resetCdmaRoamingModeToDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSetCdmaRoamingPreference(Message msg) {
|
||||
boolean isSuccessed = (boolean) msg.obj;
|
||||
|
||||
if (isSuccessed && (getValue() != null)) {
|
||||
int cdmaRoamingMode = Integer.parseInt(getValue());
|
||||
Settings.Global.putInt(
|
||||
getContext().getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
cdmaRoamingMode );
|
||||
} else {
|
||||
queryCdmaRoamingMode();
|
||||
}
|
||||
}
|
||||
|
||||
private void resetCdmaRoamingModeToDefault() {
|
||||
//set the mButtonCdmaRoam
|
||||
setValue(Integer.toString(TelephonyManager.CDMA_ROAMING_MODE_ANY));
|
||||
//set the Settings.System
|
||||
Settings.Global.putInt(
|
||||
getContext().getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
TelephonyManager.CDMA_ROAMING_MODE_ANY);
|
||||
//Set the Status
|
||||
setCdmaRoamingMode(TelephonyManager.CDMA_ROAMING_MODE_ANY);
|
||||
}
|
||||
}
|
||||
|
||||
private void queryCdmaRoamingMode() {
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
Message msg = mHandler.obtainMessage(MyHandler.MESSAGE_GET_ROAMING_PREFERENCE);
|
||||
msg.arg1 = mTelephonyManager.getCdmaRoamingMode();
|
||||
msg.sendToTarget();
|
||||
});
|
||||
}
|
||||
|
||||
private void setCdmaRoamingMode(int mode) {
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
Message msg = mHandler.obtainMessage(MyHandler.MESSAGE_SET_ROAMING_PREFERENCE);
|
||||
msg.obj = mTelephonyManager.setCdmaRoamingMode(mode);
|
||||
msg.sendToTarget();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,14 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.ims.ImsConfig;
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
@@ -58,6 +66,7 @@ import com.android.internal.telephony.PhoneConstants;
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.network.telephony.cdma.CdmaSystemSelectPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
@@ -68,14 +77,6 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class MobileNetworkFragment extends DashboardFragment implements
|
||||
Preference.OnPreferenceChangeListener, RoamingDialogFragment.RoamingDialogListener {
|
||||
@@ -160,6 +161,8 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
private NetworkSelectListPreference mButtonNetworkSelect;
|
||||
private DataUsagePreference mDataUsagePref;
|
||||
|
||||
private CdmaSystemSelectPreferenceController mCdmaSystemSelectPreferenceController;
|
||||
|
||||
private static final String iface = "rmnet0"; //TODO: this will go away
|
||||
private List<SubscriptionInfo> mActiveSubInfos;
|
||||
|
||||
@@ -394,6 +397,9 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
|
||||
use(MobileDataPreferenceController.class).init(getFragmentManager(), mSubId);
|
||||
|
||||
mCdmaSystemSelectPreferenceController = use(CdmaSystemSelectPreferenceController.class);
|
||||
mCdmaSystemSelectPreferenceController.init(getPreferenceManager(), mSubId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -721,10 +727,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
/**
|
||||
* Listen to extra preference changes that need as Metrics events logging.
|
||||
*/
|
||||
if (prefSet.findPreference(BUTTON_CDMA_SYSTEM_SELECT_KEY) != null) {
|
||||
prefSet.findPreference(BUTTON_CDMA_SYSTEM_SELECT_KEY)
|
||||
.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
if (prefSet.findPreference(BUTTON_CDMA_SUBSCRIPTION_KEY) != null) {
|
||||
prefSet.findPreference(BUTTON_CDMA_SUBSCRIPTION_KEY)
|
||||
@@ -784,10 +786,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
if (ps != null) {
|
||||
ps.setEnabled(hasActiveSubscriptions);
|
||||
}
|
||||
ps = findPreference(BUTTON_CDMA_SYSTEM_SELECT_KEY);
|
||||
if (ps != null) {
|
||||
ps.setEnabled(hasActiveSubscriptions);
|
||||
}
|
||||
ps = findPreference(CATEGORY_CALLING_KEY);
|
||||
if (ps != null) {
|
||||
ps.setEnabled(hasActiveSubscriptions);
|
||||
@@ -1096,8 +1094,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
return false;
|
||||
}
|
||||
} else if (preference == getPreferenceScreen()
|
||||
.findPreference(BUTTON_CDMA_SYSTEM_SELECT_KEY)
|
||||
|| preference == getPreferenceScreen()
|
||||
.findPreference(BUTTON_CDMA_SUBSCRIPTION_KEY)) {
|
||||
return true;
|
||||
}
|
||||
@@ -1429,13 +1425,18 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch(requestCode) {
|
||||
switch (requestCode) {
|
||||
case REQUEST_CODE_EXIT_ECM:
|
||||
Boolean isChoiceYes = data.getBooleanExtra(
|
||||
EXTRA_EXIT_ECM_RESULT, false);
|
||||
if (isChoiceYes) {
|
||||
// If the phone exits from ECM mode, show the CDMA Options
|
||||
mCdmaOptions.showDialog(mClickedPreference);
|
||||
if (TextUtils.equals(mClickedPreference.getKey(),
|
||||
mCdmaSystemSelectPreferenceController.getPreferenceKey())) {
|
||||
mCdmaSystemSelectPreferenceController.showDialog();
|
||||
} else {
|
||||
mCdmaOptions.showDialog(mClickedPreference);
|
||||
}
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
@@ -1665,13 +1666,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
return;
|
||||
}
|
||||
updateCdmaOptions(this, prefSet, mSubId);
|
||||
CdmaSystemSelectListPreference systemSelect =
|
||||
(CdmaSystemSelectListPreference)prefSet.findPreference
|
||||
(BUTTON_CDMA_SYSTEM_SELECT_KEY);
|
||||
systemSelect.setSubscriptionId(mSubId);
|
||||
if (systemSelect != null) {
|
||||
systemSelect.setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSupportTdscdma() {
|
||||
|
||||
@@ -41,6 +41,9 @@ import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.ims.ImsException;
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.internal.telephony.Phone;
|
||||
import com.android.internal.telephony.PhoneConstants;
|
||||
import com.android.settings.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -238,4 +241,86 @@ public class MobileNetworkUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if show CDMA category
|
||||
*/
|
||||
public static boolean isCdmaOptions(Context context, int subId) {
|
||||
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
return false;
|
||||
}
|
||||
final TelephonyManager telephonyManager = TelephonyManager.from(context)
|
||||
.createForSubscriptionId(subId);
|
||||
|
||||
if (telephonyManager.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isWorldMode(context, subId)) {
|
||||
final int settingsNetworkMode = android.provider.Settings.Global.getInt(
|
||||
context.getContentResolver(),
|
||||
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
|
||||
Phone.PREFERRED_NT_MODE);
|
||||
if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA
|
||||
|| settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
|
||||
&& !isTdscdmaSupported(context, telephonyManager)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if it is world mode, and we may show advanced options in telephony
|
||||
* settings
|
||||
*/
|
||||
public static boolean isWorldMode(Context context, int subId) {
|
||||
final TelephonyManager telephonyManager = TelephonyManager.from(context)
|
||||
.createForSubscriptionId(subId);
|
||||
boolean worldModeOn = false;
|
||||
final String configString = context.getString(R.string.config_world_mode);
|
||||
|
||||
if (!TextUtils.isEmpty(configString)) {
|
||||
String[] configArray = configString.split(";");
|
||||
// Check if we have World mode configuration set to True only or config is set to True
|
||||
// and SIM GID value is also set and matches to the current SIM GID.
|
||||
if (configArray != null &&
|
||||
((configArray.length == 1 && configArray[0].equalsIgnoreCase("true"))
|
||||
|| (configArray.length == 2 && !TextUtils.isEmpty(configArray[1])
|
||||
&& telephonyManager != null
|
||||
&& configArray[1].equalsIgnoreCase(
|
||||
telephonyManager.getGroupIdLevel1())))) {
|
||||
worldModeOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
Log.d(TAG, "isWorldMode=" + worldModeOn);
|
||||
|
||||
return worldModeOn;
|
||||
}
|
||||
|
||||
//TODO(b/117651939): move it to telephony
|
||||
private static boolean isTdscdmaSupported(Context context, TelephonyManager telephonyManager) {
|
||||
if (context.getResources().getBoolean(R.bool.config_support_tdscdma)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String operatorNumeric = telephonyManager.getServiceState().getOperatorNumeric();
|
||||
String[] numericArray = context.getResources().getStringArray(
|
||||
R.array.config_support_tdscdma_roaming_on_networks);
|
||||
if (numericArray.length == 0 || operatorNumeric == null) {
|
||||
return false;
|
||||
}
|
||||
for (String numeric : numericArray) {
|
||||
if (operatorNumeric.equals(numeric)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.cdma;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
/**
|
||||
* Preference controller for "System Select"
|
||||
*/
|
||||
public class CdmaSystemSelectPreferenceController extends BasePreferenceController
|
||||
implements LifecycleObserver, OnStart, OnStop, ListPreference.OnPreferenceChangeListener {
|
||||
|
||||
@VisibleForTesting
|
||||
ListPreference mPreference;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private PreferenceManager mPreferenceManager;
|
||||
private DataContentObserver mDataContentObserver;
|
||||
private int mSubId;
|
||||
|
||||
public CdmaSystemSelectPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mDataContentObserver = new DataContentObserver(new Handler(Looper.getMainLooper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
mDataContentObserver.register(mContext, mSubId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
mDataContentObserver.unRegister(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return MobileNetworkUtils.isCdmaOptions(mContext, mSubId)
|
||||
? AVAILABLE
|
||||
: CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
final ListPreference listPreference = (ListPreference) preference;
|
||||
listPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
|
||||
final int mode = mTelephonyManager.getCdmaRoamingMode();
|
||||
if (mode != TelephonyManager.CDMA_ROAMING_MODE_RADIO_DEFAULT) {
|
||||
if (mode == TelephonyManager.CDMA_ROAMING_MODE_HOME
|
||||
|| mode == TelephonyManager.CDMA_ROAMING_MODE_ANY) {
|
||||
listPreference.setValue(Integer.toString(mode));
|
||||
} else {
|
||||
resetCdmaRoamingModeToDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object object) {
|
||||
int newMode = Integer.parseInt((String) object);
|
||||
//TODO(b/117611981): only set it in one place
|
||||
if (mTelephonyManager.setCdmaRoamingMode(newMode)) {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE, newMode);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void init(PreferenceManager preferenceManager, int subId) {
|
||||
mPreferenceManager = preferenceManager;
|
||||
mSubId = subId;
|
||||
mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
if (!mTelephonyManager.getEmergencyCallbackMode()) {
|
||||
mPreferenceManager.showDialog(mPreference);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetCdmaRoamingModeToDefault() {
|
||||
//set the mButtonCdmaRoam
|
||||
mPreference.setValue(Integer.toString(TelephonyManager.CDMA_ROAMING_MODE_ANY));
|
||||
//set the Settings.System
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.CDMA_ROAMING_MODE,
|
||||
TelephonyManager.CDMA_ROAMING_MODE_ANY);
|
||||
//Set the Status
|
||||
mTelephonyManager.setCdmaRoamingMode(TelephonyManager.CDMA_ROAMING_MODE_ANY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener that listens mobile data state change.
|
||||
*/
|
||||
public class DataContentObserver extends ContentObserver {
|
||||
|
||||
public DataContentObserver(Handler handler) {
|
||||
super(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
super.onChange(selfChange);
|
||||
updateState(mPreference);
|
||||
}
|
||||
|
||||
public void register(Context context, int subId) {
|
||||
Uri uri = Settings.Global.getUriFor(Settings.Global.PREFERRED_NETWORK_MODE + subId);
|
||||
context.getContentResolver().registerContentObserver(uri, false, this);
|
||||
}
|
||||
|
||||
public void unRegister(Context context) {
|
||||
context.getContentResolver().unregisterContentObserver(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,13 +87,13 @@ public class NotificationAccessConfirmationActivity extends Activity
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getWindow().addFlags(
|
||||
WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
getWindow().clearFlags(
|
||||
WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
||||
@@ -118,9 +118,9 @@ public class WebViewAppPicker extends DefaultAppPickerFragment {
|
||||
}
|
||||
|
||||
private static class WebViewAppInfo extends DefaultAppInfo {
|
||||
public WebViewAppInfo(Context context, PackageManager pm,
|
||||
public WebViewAppInfo(Context context, PackageManager pm, int userId,
|
||||
PackageItemInfo packageItemInfo, String summary, boolean enabled) {
|
||||
super(context, pm, packageItemInfo, summary, enabled);
|
||||
super(context, pm, userId, packageItemInfo, summary, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,7 +138,7 @@ public class WebViewAppPicker extends DefaultAppPickerFragment {
|
||||
@VisibleForTesting
|
||||
DefaultAppInfo createDefaultAppInfo(Context context, PackageManager pm,
|
||||
PackageItemInfo packageItemInfo, String disabledReason) {
|
||||
return new WebViewAppInfo(context, pm, packageItemInfo, disabledReason,
|
||||
return new WebViewAppInfo(context, pm, mUserId, packageItemInfo, disabledReason,
|
||||
TextUtils.isEmpty(disabledReason) /* enabled */);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,12 +43,11 @@ import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;import android.net.INetworkStatsSession;
|
||||
import org.mockito.Mock;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -18,8 +18,8 @@ package com.android.settings.applications.appinfo;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.argThat;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -66,8 +66,8 @@ public class DefaultBrowserShortcutPreferenceControllerTest {
|
||||
public void hasAppCapability_hasBrowserCapability_shouldReturnTrue() {
|
||||
List<ResolveInfo> resolveInfos = new ArrayList<>();
|
||||
resolveInfos.add(new ResolveInfo());
|
||||
when(mPackageManager.queryIntentActivities(argThat(intent-> intent != null
|
||||
&& intent.getCategories().contains(Intent.CATEGORY_BROWSABLE)), anyInt()))
|
||||
when(mPackageManager.queryIntentActivitiesAsUser(argThat(intent-> intent != null
|
||||
&& intent.getCategories().contains(Intent.CATEGORY_BROWSABLE)), anyInt(), anyInt()))
|
||||
.thenReturn(resolveInfos);
|
||||
|
||||
assertThat(mController.hasAppCapability()).isTrue();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.applications.appinfo;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Matchers.eq;
|
||||
@@ -91,7 +91,7 @@ public class DrawOverlayDetailsTest {
|
||||
when(mWindow.getAttributes()).thenReturn(layoutParams);
|
||||
|
||||
mFragment.onResume();
|
||||
verify(mWindow).addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
|
||||
mFragment.onPause();
|
||||
|
||||
@@ -99,6 +99,6 @@ public class DrawOverlayDetailsTest {
|
||||
ArgumentCaptor<LayoutParams> paramCaptor = ArgumentCaptor.forClass(LayoutParams.class);
|
||||
verify(mWindow).setAttributes(paramCaptor.capture());
|
||||
assertEquals(0,
|
||||
paramCaptor.getValue().privateFlags & PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
paramCaptor.getValue().privateFlags & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
@@ -130,6 +131,16 @@ public class DefaultBrowserPreferenceControllerTest {
|
||||
verify(mPackageManager).getDefaultBrowserPackageNameAsUser(anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefaultApp_shouldGetApplicationInfoAsUser() throws NameNotFoundException {
|
||||
final String PACKAGE_NAME = "com.test.package";
|
||||
when(mPackageManager.getDefaultBrowserPackageNameAsUser(anyInt())).thenReturn(PACKAGE_NAME);
|
||||
|
||||
mController.getDefaultAppInfo();
|
||||
|
||||
verify(mPackageManager).getApplicationInfoAsUser(eq(PACKAGE_NAME), anyInt(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isBrowserDefault_onlyApp_shouldReturnTrue() {
|
||||
when(mPackageManager.getDefaultBrowserPackageNameAsUser(anyInt())).thenReturn(null);
|
||||
@@ -173,6 +184,33 @@ public class DefaultBrowserPreferenceControllerTest {
|
||||
any(Intent.class), eq(0) /* flags */, eq(0) /* userId */);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOnlyAppIcon_shouldGetApplicationInfoAsUser() throws NameNotFoundException {
|
||||
final List<ResolveInfo> resolveInfos = new ArrayList<>();
|
||||
final String PACKAGE_NAME = "com.test.package";
|
||||
resolveInfos.add(createResolveInfo(PACKAGE_NAME));
|
||||
when(mPackageManager.queryIntentActivitiesAsUser(any(Intent.class), anyInt(), anyInt()))
|
||||
.thenReturn(resolveInfos);
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||
when(mContext.getResources()).thenReturn(mock(Resources.class));
|
||||
|
||||
mController.getOnlyAppIcon();
|
||||
|
||||
verify(mPackageManager).getApplicationInfoAsUser(
|
||||
eq(PACKAGE_NAME), eq(0) /* flags */, eq(0) /* userId */);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasBrowserPreference_shouldQueryIntentActivitiesAsUser() {
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
|
||||
mController.hasBrowserPreference("com.test.package", mContext, 0 /* userId */);
|
||||
|
||||
verify(mPackageManager).queryIntentActivitiesAsUser(
|
||||
any(Intent.class), eq(0) /* flags */, eq(0) /* userId */);
|
||||
}
|
||||
|
||||
private ResolveInfo createResolveInfo(String packageName) {
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.handleAllWebDataURI = true;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.settings.network.telephony;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
@@ -32,11 +31,14 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.provider.Settings;
|
||||
import android.telecom.PhoneAccountHandle;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import com.android.internal.telephony.PhoneConstants;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -142,4 +144,22 @@ public class MobileNetworkUtilsTest {
|
||||
assertThat(MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
|
||||
mPhoneAccountHandle)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isCdmaOptions_phoneTypeCdma_returnTrue() {
|
||||
doReturn(PhoneConstants.PHONE_TYPE_CDMA).when(mTelephonyManager).getPhoneType();
|
||||
|
||||
assertThat(MobileNetworkUtils.isCdmaOptions(mContext, SUB_ID_1)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isCdmaOptions_worldModeWithGsmWcdma_returnTrue() {
|
||||
doReturn(PhoneConstants.PHONE_TYPE_GSM).when(mTelephonyManager).getPhoneType();
|
||||
doReturn("true").when(mContext).getString(R.string.config_world_mode);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
|
||||
TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
|
||||
|
||||
assertThat(MobileNetworkUtils.isCdmaOptions(mContext, SUB_ID_1)).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.cdma;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class CdmaSystemSelectPreferenceControllerTest {
|
||||
private static final int SUB_ID = 2;
|
||||
|
||||
@Mock
|
||||
private PreferenceManager mPreferenceManager;
|
||||
@Mock
|
||||
private TelephonyManager mTelephonyManager;
|
||||
@Mock
|
||||
private TelephonyManager mInvalidTelephonyManager;
|
||||
@Mock
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
|
||||
private CdmaSystemSelectPreferenceController mController;
|
||||
private ListPreference mPreference;
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
|
||||
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
|
||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
||||
doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
|
||||
mPreference = new ListPreference(mContext);
|
||||
mController = new CdmaSystemSelectPreferenceController(mContext, "mobile_data");
|
||||
mController.init(mPreferenceManager, SUB_ID);
|
||||
mController.mPreference = mPreference;
|
||||
mPreference.setKey(mController.getPreferenceKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_selectHome_returnHomeMode() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
TelephonyManager.CDMA_ROAMING_MODE_ANY);
|
||||
doReturn(true).when(mTelephonyManager).setCdmaRoamingMode(anyInt());
|
||||
|
||||
mController.onPreferenceChange(mPreference,
|
||||
Integer.toString(TelephonyManager.CDMA_ROAMING_MODE_HOME));
|
||||
|
||||
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
TelephonyManager.CDMA_ROAMING_MODE_ANY)).isEqualTo(
|
||||
TelephonyManager.CDMA_ROAMING_MODE_HOME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_stateHome_displayHome() {
|
||||
doReturn(TelephonyManager.CDMA_ROAMING_MODE_HOME).when(
|
||||
mTelephonyManager).getCdmaRoamingMode();
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getValue()).isEqualTo(
|
||||
Integer.toString(TelephonyManager.CDMA_ROAMING_MODE_HOME));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_stateOther_resetToDefault() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
TelephonyManager.CDMA_ROAMING_MODE_HOME);
|
||||
doReturn(TelephonyManager.CDMA_ROAMING_MODE_AFFILIATED).when(
|
||||
mTelephonyManager).getCdmaRoamingMode();
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getValue()).isEqualTo(
|
||||
Integer.toString(TelephonyManager.CDMA_ROAMING_MODE_ANY));
|
||||
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.CDMA_ROAMING_MODE,
|
||||
TelephonyManager.CDMA_ROAMING_MODE_HOME)).isEqualTo(
|
||||
TelephonyManager.CDMA_ROAMING_MODE_ANY);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user