Snap for 8617226 from 08b7f53383
to tm-release
Change-Id: Ib27ab8dc609696fd43a52b26b3c786591f598564
This commit is contained in:
@@ -260,6 +260,9 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getTransitionType(Intent intent) {
|
private int getTransitionType(Intent intent) {
|
||||||
|
if (intent == null) {
|
||||||
|
return TransitionType.TRANSITION_NONE;
|
||||||
|
}
|
||||||
return intent.getIntExtra(EXTRA_PAGE_TRANSITION_TYPE, TransitionType.TRANSITION_NONE);
|
return intent.getIntExtra(EXTRA_PAGE_TRANSITION_TYPE, TransitionType.TRANSITION_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ import android.content.Intent;
|
|||||||
import android.icu.text.RelativeDateTimeFormatter;
|
import android.icu.text.RelativeDateTimeFormatter;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -27,6 +28,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||||
@@ -82,8 +84,11 @@ public class RecentLocationAccessPreferenceController extends LocationBasePrefer
|
|||||||
RecentAppOpsAccess recentLocationApps) {
|
RecentAppOpsAccess recentLocationApps) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mRecentLocationApps = recentLocationApps;
|
mRecentLocationApps = recentLocationApps;
|
||||||
mShowSystem = Settings.Secure.getInt(mContext.getContentResolver(),
|
mShowSystem = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
SystemUiDeviceConfigFlags.PROPERTY_LOCATION_INDICATORS_SMALL_ENABLED, false)
|
||||||
|
? Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1
|
||||||
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -17,11 +17,13 @@ package com.android.settings.location;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
@@ -58,8 +60,11 @@ public class RecentLocationAccessSeeAllFragment extends DashboardFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mShowSystem = Settings.Secure.getInt(getContentResolver(),
|
mShowSystem = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
SystemUiDeviceConfigFlags.PROPERTY_LOCATION_INDICATORS_SMALL_ENABLED, false)
|
||||||
|
? Settings.Secure.getInt(getContentResolver(),
|
||||||
|
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1
|
||||||
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -20,11 +20,13 @@ import static com.android.settings.location.RecentLocationAccessPreferenceContro
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
@@ -48,8 +50,12 @@ public class RecentLocationAccessSeeAllPreferenceController
|
|||||||
|
|
||||||
public RecentLocationAccessSeeAllPreferenceController(Context context, String key) {
|
public RecentLocationAccessSeeAllPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mShowSystem = Settings.Secure.getInt(mContext.getContentResolver(),
|
mShowSystem = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
SystemUiDeviceConfigFlags.PROPERTY_LOCATION_INDICATORS_SMALL_ENABLED, false)
|
||||||
|
? Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1
|
||||||
|
: false;
|
||||||
|
|
||||||
mRecentLocationAccesses = RecentAppOpsAccess.createForLocation(context);
|
mRecentLocationAccesses = RecentAppOpsAccess.createForLocation(context);
|
||||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -24,6 +25,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
@@ -84,8 +86,11 @@ public class RecentLocationRequestPreferenceController extends LocationBasePrefe
|
|||||||
final Context prefContext = mCategoryRecentLocationRequests.getContext();
|
final Context prefContext = mCategoryRecentLocationRequests.getContext();
|
||||||
final List<RecentLocationApps.Request> recentLocationRequests = new ArrayList<>();
|
final List<RecentLocationApps.Request> recentLocationRequests = new ArrayList<>();
|
||||||
final UserManager userManager = UserManager.get(mContext);
|
final UserManager userManager = UserManager.get(mContext);
|
||||||
final boolean showSystem = Settings.Secure.getInt(mContext.getContentResolver(),
|
final boolean showSystem = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
SystemUiDeviceConfigFlags.PROPERTY_LOCATION_INDICATORS_SMALL_ENABLED, false)
|
||||||
|
? Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1
|
||||||
|
: false;
|
||||||
|
|
||||||
for (RecentLocationApps.Request request : mRecentLocationApps.getAppListSorted(
|
for (RecentLocationApps.Request request : mRecentLocationApps.getAppListSorted(
|
||||||
showSystem)) {
|
showSystem)) {
|
||||||
|
@@ -456,7 +456,11 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTelephonyDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo) {
|
public void onTelephonyDisplayInfoChanged(int subId,
|
||||||
|
TelephonyDisplayInfo telephonyDisplayInfo) {
|
||||||
|
if (subId != mSubsPrefCtrlInjector.getDefaultDataSubscriptionId()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mTelephonyDisplayInfo = telephonyDisplayInfo;
|
mTelephonyDisplayInfo = telephonyDisplayInfo;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@@ -37,8 +37,9 @@ public class TelephonyDisplayInfoListener {
|
|||||||
private TelephonyManager mBaseTelephonyManager;
|
private TelephonyManager mBaseTelephonyManager;
|
||||||
private Callback mCallback;
|
private Callback mCallback;
|
||||||
private Map<Integer, PhoneStateListener> mListeners;
|
private Map<Integer, PhoneStateListener> mListeners;
|
||||||
|
private Map<Integer, TelephonyDisplayInfo> mDisplayInfos;
|
||||||
|
|
||||||
private TelephonyDisplayInfo mTelephonyDisplayInfo =
|
private static final TelephonyDisplayInfo mDefaultTelephonyDisplayInfo =
|
||||||
new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN,
|
new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN,
|
||||||
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
|
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
|
||||||
/**
|
/**
|
||||||
@@ -48,19 +49,20 @@ public class TelephonyDisplayInfoListener {
|
|||||||
/**
|
/**
|
||||||
* Used to notify TelephonyDisplayInfo change.
|
* Used to notify TelephonyDisplayInfo change.
|
||||||
*/
|
*/
|
||||||
void onTelephonyDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo);
|
void onTelephonyDisplayInfoChanged(int subId, TelephonyDisplayInfo telephonyDisplayInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TelephonyDisplayInfoListener(Context context, Callback callback) {
|
public TelephonyDisplayInfoListener(Context context, Callback callback) {
|
||||||
mBaseTelephonyManager = context.getSystemService(TelephonyManager.class);
|
mBaseTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
mListeners = new HashMap<>();
|
mListeners = new HashMap<>();
|
||||||
|
mDisplayInfos = new HashMap<>();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get TelephonyDisplayInfo.
|
* Get TelephonyDisplayInfo.
|
||||||
*/
|
*/
|
||||||
public TelephonyDisplayInfo getTelephonyDisplayInfo() {
|
public TelephonyDisplayInfo getTelephonyDisplayInfo(int subId) {
|
||||||
return mTelephonyDisplayInfo;
|
return mDisplayInfos.get(subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resumes listening telephony display info changes to the set of ids from the last call to
|
/** Resumes listening telephony display info changes to the set of ids from the last call to
|
||||||
@@ -85,15 +87,17 @@ public class TelephonyDisplayInfoListener {
|
|||||||
for (int idToRemove : Sets.difference(currentIds, ids)) {
|
for (int idToRemove : Sets.difference(currentIds, ids)) {
|
||||||
stopListening(idToRemove);
|
stopListening(idToRemove);
|
||||||
mListeners.remove(idToRemove);
|
mListeners.remove(idToRemove);
|
||||||
|
mDisplayInfos.remove(idToRemove);
|
||||||
}
|
}
|
||||||
for (int idToAdd : Sets.difference(ids, currentIds)) {
|
for (int idToAdd : Sets.difference(ids, currentIds)) {
|
||||||
PhoneStateListener listener = new PhoneStateListener() {
|
PhoneStateListener listener = new PhoneStateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo) {
|
public void onDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo) {
|
||||||
mTelephonyDisplayInfo = telephonyDisplayInfo;
|
mDisplayInfos.put(idToAdd, telephonyDisplayInfo);
|
||||||
mCallback.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
|
mCallback.onTelephonyDisplayInfoChanged(idToAdd, telephonyDisplayInfo);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
mDisplayInfos.put(idToAdd, mDefaultTelephonyDisplayInfo);
|
||||||
mListeners.put(idToAdd, listener);
|
mListeners.put(idToAdd, listener);
|
||||||
startListening(idToAdd);
|
startListening(idToAdd);
|
||||||
}
|
}
|
||||||
|
@@ -52,6 +52,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference controller for "Auto Select Network"
|
* Preference controller for "Auto Select Network"
|
||||||
@@ -70,11 +72,17 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
ProgressDialog mProgressDialog;
|
ProgressDialog mProgressDialog;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SwitchPreference mSwitchPreference;
|
SwitchPreference mSwitchPreference;
|
||||||
|
private AtomicBoolean mUpdatingConfig;
|
||||||
|
private int mCacheOfModeStatus;
|
||||||
|
private AtomicLong mRecursiveUpdate;
|
||||||
|
|
||||||
public AutoSelectPreferenceController(Context context, String key) {
|
public AutoSelectPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
|
mRecursiveUpdate = new AtomicLong();
|
||||||
|
mUpdatingConfig = new AtomicBoolean();
|
||||||
|
mCacheOfModeStatus = TelephonyManager.NETWORK_SELECTION_MODE_UNKNOWN;
|
||||||
mListeners = new ArrayList<>();
|
mListeners = new ArrayList<>();
|
||||||
mUiHandler = new Handler(Looper.getMainLooper());
|
mUiHandler = new Handler(Looper.getMainLooper());
|
||||||
mAllowedNetworkTypesListener = new AllowedNetworkTypesListener(
|
mAllowedNetworkTypesListener = new AllowedNetworkTypesListener(
|
||||||
@@ -88,7 +96,9 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
displayPreference(mPreferenceScreen);
|
displayPreference(mPreferenceScreen);
|
||||||
}
|
}
|
||||||
if (mSwitchPreference != null) {
|
if (mSwitchPreference != null) {
|
||||||
|
mRecursiveUpdate.getAndIncrement();
|
||||||
updateState(mSwitchPreference);
|
updateState(mSwitchPreference);
|
||||||
|
mRecursiveUpdate.decrementAndGet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,8 +128,13 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return mTelephonyManager.getNetworkSelectionMode()
|
if (!mUpdatingConfig.get()) {
|
||||||
== TelephonyManager.NETWORK_SELECTION_MODE_AUTO;
|
mCacheOfModeStatus = mTelephonyManager.getNetworkSelectionMode();
|
||||||
|
for (OnNetworkSelectModeListener lsn : mListeners) {
|
||||||
|
lsn.onNetworkSelectModeUpdated(mCacheOfModeStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mCacheOfModeStatus == TelephonyManager.NETWORK_SELECTION_MODE_AUTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -147,6 +162,10 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setChecked(boolean isChecked) {
|
public boolean setChecked(boolean isChecked) {
|
||||||
|
if (mRecursiveUpdate.get() != 0) {
|
||||||
|
// Changing from software are allowed and changing presentation only.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
setAutomaticSelectionMode();
|
setAutomaticSelectionMode();
|
||||||
} else {
|
} else {
|
||||||
@@ -171,18 +190,17 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
}
|
}
|
||||||
return ThreadUtils.postOnBackgroundThread(() -> {
|
return ThreadUtils.postOnBackgroundThread(() -> {
|
||||||
// set network selection mode in background
|
// set network selection mode in background
|
||||||
|
mUpdatingConfig.set(true);
|
||||||
mTelephonyManager.setNetworkSelectionModeAutomatic();
|
mTelephonyManager.setNetworkSelectionModeAutomatic();
|
||||||
final int mode = mTelephonyManager.getNetworkSelectionMode();
|
mUpdatingConfig.set(false);
|
||||||
|
|
||||||
//Update UI in UI thread
|
//Update UI in UI thread
|
||||||
final long durationMillis = SystemClock.elapsedRealtime() - startMillis;
|
final long durationMillis = SystemClock.elapsedRealtime() - startMillis;
|
||||||
mUiHandler.postDelayed(() -> {
|
mUiHandler.postDelayed(() -> {
|
||||||
|
mRecursiveUpdate.getAndIncrement();
|
||||||
mSwitchPreference.setEnabled(true);
|
mSwitchPreference.setEnabled(true);
|
||||||
mSwitchPreference.setChecked(
|
mSwitchPreference.setChecked(isChecked());
|
||||||
mode == TelephonyManager.NETWORK_SELECTION_MODE_AUTO);
|
mRecursiveUpdate.decrementAndGet();
|
||||||
for (OnNetworkSelectModeListener lsn : mListeners) {
|
|
||||||
lsn.onNetworkSelectModeChanged();
|
|
||||||
}
|
|
||||||
dismissProgressBar();
|
dismissProgressBar();
|
||||||
}, Math.max(MINIMUM_DIALOG_TIME_MILLIS - durationMillis, 0));
|
}, Math.max(MINIMUM_DIALOG_TIME_MILLIS - durationMillis, 0));
|
||||||
});
|
});
|
||||||
@@ -232,11 +250,11 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback when network select mode is changed
|
* Callback when network select mode might get updated
|
||||||
*
|
*
|
||||||
* @see TelephonyManager#getNetworkSelectionMode()
|
* @see TelephonyManager#getNetworkSelectionMode()
|
||||||
*/
|
*/
|
||||||
public interface OnNetworkSelectModeListener {
|
public interface OnNetworkSelectModeListener {
|
||||||
void onNetworkSelectModeChanged();
|
void onNetworkSelectModeUpdated(int mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,11 +48,13 @@ public class OpenNetworkSelectPagePreferenceController extends
|
|||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
private PreferenceScreen mPreferenceScreen;
|
private PreferenceScreen mPreferenceScreen;
|
||||||
private AllowedNetworkTypesListener mAllowedNetworkTypesListener;
|
private AllowedNetworkTypesListener mAllowedNetworkTypesListener;
|
||||||
|
private int mCacheOfModeStatus;
|
||||||
|
|
||||||
public OpenNetworkSelectPagePreferenceController(Context context, String key) {
|
public OpenNetworkSelectPagePreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
|
mCacheOfModeStatus = TelephonyManager.NETWORK_SELECTION_MODE_UNKNOWN;
|
||||||
mAllowedNetworkTypesListener = new AllowedNetworkTypesListener(
|
mAllowedNetworkTypesListener = new AllowedNetworkTypesListener(
|
||||||
context.getMainExecutor());
|
context.getMainExecutor());
|
||||||
mAllowedNetworkTypesListener.setAllowedNetworkTypesListener(
|
mAllowedNetworkTypesListener.setAllowedNetworkTypesListener(
|
||||||
@@ -96,7 +98,7 @@ public class OpenNetworkSelectPagePreferenceController extends
|
|||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
super.updateState(preference);
|
super.updateState(preference);
|
||||||
preference.setEnabled(mTelephonyManager.getNetworkSelectionMode()
|
preference.setEnabled(mCacheOfModeStatus
|
||||||
!= TelephonyManager.NETWORK_SELECTION_MODE_AUTO);
|
!= TelephonyManager.NETWORK_SELECTION_MODE_AUTO);
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
@@ -125,7 +127,10 @@ public class OpenNetworkSelectPagePreferenceController extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNetworkSelectModeChanged() {
|
public void onNetworkSelectModeUpdated(int mode) {
|
||||||
updateState(mPreference);
|
mCacheOfModeStatus = mode;
|
||||||
|
if (mPreference != null) {
|
||||||
|
updateState(mPreference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,15 +26,19 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
||||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||||
import com.android.settingslib.location.RecentLocationApps;
|
import com.android.settingslib.location.RecentLocationApps;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -50,7 +54,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowUserManager.class})
|
@Config(shadows = {ShadowDeviceConfig.class, ShadowUserManager.class})
|
||||||
public class RecentLocationRequestPreferenceControllerTest {
|
public class RecentLocationRequestPreferenceControllerTest {
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@@ -72,6 +76,11 @@ public class RecentLocationRequestPreferenceControllerTest {
|
|||||||
mController.mRecentLocationApps = spy(new RecentLocationApps(mContext));
|
mController.mRecentLocationApps = spy(new RecentLocationApps(mContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowDeviceConfig.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_whenAppListMoreThanThree_shouldDisplayTopThreeApps() {
|
public void updateState_whenAppListMoreThanThree_shouldDisplayTopThreeApps() {
|
||||||
final List<RecentLocationApps.Request> requests = createMockRequest(6);
|
final List<RecentLocationApps.Request> requests = createMockRequest(6);
|
||||||
@@ -84,6 +93,10 @@ public class RecentLocationRequestPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_whenAppListMoreThanThree_showSystem() {
|
public void updateState_whenAppListMoreThanThree_showSystem() {
|
||||||
|
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
SystemUiDeviceConfigFlags.PROPERTY_LOCATION_INDICATORS_SMALL_ENABLED,
|
||||||
|
Boolean.toString(true),
|
||||||
|
true);
|
||||||
when(mController.mRecentLocationApps.getAppListSorted(false))
|
when(mController.mRecentLocationApps.getAppListSorted(false))
|
||||||
.thenReturn(createMockRequest(2));
|
.thenReturn(createMockRequest(2));
|
||||||
when(mController.mRecentLocationApps.getAppListSorted(true))
|
when(mController.mRecentLocationApps.getAppListSorted(true))
|
||||||
|
@@ -364,7 +364,8 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
mController.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
|
mController.onTelephonyDisplayInfoChanged(sub.get(0).getSubscriptionId(),
|
||||||
|
telephonyDisplayInfo);
|
||||||
|
|
||||||
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
|
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
|
||||||
}
|
}
|
||||||
@@ -388,7 +389,8 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
mController.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
|
mController.onTelephonyDisplayInfoChanged(sub.get(0).getSubscriptionId(),
|
||||||
|
telephonyDisplayInfo);
|
||||||
|
|
||||||
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
|
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
|
||||||
}
|
}
|
||||||
@@ -414,7 +416,8 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
mController.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
|
mController.onTelephonyDisplayInfoChanged(sub.get(0).getSubscriptionId(),
|
||||||
|
telephonyDisplayInfo);
|
||||||
|
|
||||||
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
|
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
|
||||||
}
|
}
|
||||||
|
@@ -93,15 +93,18 @@ public class OpenNetworkSelectPagePreferenceControllerTest {
|
|||||||
|
|
||||||
mPreference = new Preference(mContext);
|
mPreference = new Preference(mContext);
|
||||||
mController = new OpenNetworkSelectPagePreferenceController(mContext,
|
mController = new OpenNetworkSelectPagePreferenceController(mContext,
|
||||||
"open_network_select");
|
"open_network_select") {
|
||||||
|
@Override
|
||||||
|
public void updateState(Preference preference) {
|
||||||
|
super.updateState(mPreference);
|
||||||
|
}
|
||||||
|
};
|
||||||
mController.init(mLifecycle, SUB_ID);
|
mController.init(mLifecycle, SUB_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_modeAuto_disabled() {
|
public void updateState_modeAuto_disabled() {
|
||||||
when(mTelephonyManager.getNetworkSelectionMode()).thenReturn(
|
mController.onNetworkSelectModeUpdated(TelephonyManager.NETWORK_SELECTION_MODE_AUTO);
|
||||||
TelephonyManager.NETWORK_SELECTION_MODE_AUTO);
|
|
||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isFalse();
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
|
Reference in New Issue
Block a user