Snap for 5280121 from 12cec79889 to qt-release
Change-Id: I1571f7c5af4261b2757cb1cb9948f453c8dc79ef
This commit is contained in:
@@ -1825,7 +1825,7 @@
|
||||
<activity
|
||||
android:name="Settings$PrintSettingsActivity"
|
||||
android:label="@string/print_settings"
|
||||
android:icon="@*android:drawable/ic_settings_print"
|
||||
android:icon="@drawable/ic_settings_print"
|
||||
android:parentActivityName="Settings">
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.settings.ACTION_PRINT_SETTINGS" />
|
||||
@@ -2591,6 +2591,12 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".wifi.slice.ConnectToWifiHandler"
|
||||
android:theme="@android:style/Theme.NoDisplay"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="false" />
|
||||
|
||||
<activity android:name=".sim.SimDialogActivity"
|
||||
android:theme="@style/Theme.AlertDialog"
|
||||
android:label="@string/sim_settings_title"
|
||||
|
||||
22
res/drawable/ic_settings_print.xml
Normal file
22
res/drawable/ic_settings_print.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<!-- Pass through drawable to framework ic_settings_print. This is necessary because this drawable
|
||||
is used in AndroidManifest.xml and aapt cannot find drawable reference from outside of Settings
|
||||
apk. -->
|
||||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:src="@*android:drawable/ic_settings_print"/>
|
||||
64
res/layout/dialog_mobile_network_rename.xml
Normal file
64
res/layout/dialog_mobile_network_rename.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/sim_content_padding">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edittext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text"
|
||||
android:maxLength="50"
|
||||
android:singleLine="true">
|
||||
<requestFocus/>
|
||||
</EditText>
|
||||
|
||||
<TextView
|
||||
style="@style/device_info_dialog_label"
|
||||
android:id="@+id/operator_name_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/status_operator"/>
|
||||
<TextView
|
||||
style="@style/device_info_dialog_value"
|
||||
android:id="@+id/operator_name_value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/device_info_not_available"/>
|
||||
|
||||
<TextView
|
||||
style="@style/device_info_dialog_label"
|
||||
android:id="@+id/number_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/status_number_sim_status"/>
|
||||
<TextView
|
||||
style="@style/device_info_dialog_value"
|
||||
android:id="@+id/number_value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/device_info_not_available"/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
@@ -31,4 +31,7 @@
|
||||
<item type="id" name="action_drag_move_top" />
|
||||
<item type="id" name="action_drag_move_bottom" />
|
||||
<item type="id" name="action_drag_remove" />
|
||||
|
||||
<!-- For a menu item allowing users to edit a SIM display name -->
|
||||
<item type="id" name="edit_sim_name" />
|
||||
</resources>
|
||||
|
||||
@@ -7056,7 +7056,9 @@
|
||||
<string name="keywords_sim_status">network, mobile network state, service state, signal strength, mobile network type, roaming, iccid</string>
|
||||
<string name="keywords_model_and_hardware">serial number, hardware version</string>
|
||||
<string name="keywords_android_version">android security patch level, baseband version, kernel version</string>
|
||||
<!--Search keywords for financial apps sms access settings -->
|
||||
<!-- Search keywords for dark mode settings [CHAR LIMIT=NONE] -->
|
||||
<string name="keywords_dark_ui_mode">theme, light, dark, mode</string>
|
||||
<!-- Search keywords for financial apps sms access settings [CHAR LIMIT=NONE] -->
|
||||
<string name="keywords_financial_apps_sms_access">financial app, sms, permission</string>
|
||||
|
||||
<!-- Search keyword for Device Theme Settings [CHAR LIMIT=NONE] -->
|
||||
@@ -10456,6 +10458,14 @@
|
||||
<!-- Summary for an item in the page listing multiple mobile service subscriptions, indicating
|
||||
that service is inactive and is tied to an eSIM profile [CHAR LIMIT=40] -->
|
||||
<string name="mobile_network_inactive_esim">Inactive eSIM</string>
|
||||
<!-- Title of a dialog that lets a user modify the display name used for a mobile network
|
||||
subscription in various places in the Settings app. The default name is typically just the
|
||||
carrier name, but especially in multi-SIM configurations users may want to use a different
|
||||
name. [CHAR LIMIT=40] -->
|
||||
<string name="mobile_network_sim_name">SIM name</string>
|
||||
<!-- Label on the confirmation button of a dialog that lets a user set the display name of a
|
||||
mobile network subscription [CHAR LIMIT=20] -->
|
||||
<string name="mobile_network_sim_name_rename">Rename</string>
|
||||
|
||||
<!-- Title for preferred network type [CHAR LIMIT=NONE] -->
|
||||
<string name="preferred_network_mode_title">Preferred network type</string>
|
||||
|
||||
@@ -141,6 +141,7 @@
|
||||
android:dialogTitle="@string/dark_ui_mode_title"
|
||||
android:entries="@array/dark_ui_mode_entries"
|
||||
android:entryValues="@array/dark_ui_mode_values"
|
||||
settings:keywords="@string/keywords_dark_ui_mode"
|
||||
settings:controller="com.android.settings.display.DarkUIPreferenceController" />
|
||||
|
||||
<ListPreference
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -56,6 +59,8 @@ public class AccountDetailDashboardFragment extends DashboardFragment {
|
||||
String mAccountType;
|
||||
private AccountSyncPreferenceController mAccountSynController;
|
||||
private RemoveAccountPreferenceController mRemoveAccountController;
|
||||
@VisibleForTesting
|
||||
UserHandle mUserHandle;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -63,7 +68,7 @@ public class AccountDetailDashboardFragment extends DashboardFragment {
|
||||
getPreferenceManager().setPreferenceComparisonCallback(null);
|
||||
Bundle args = getArguments();
|
||||
final Activity activity = getActivity();
|
||||
UserHandle userHandle = Utils.getSecureTargetUser(activity.getActivityToken(),
|
||||
mUserHandle = Utils.getSecureTargetUser(activity.getActivityToken(),
|
||||
(UserManager) getSystemService(Context.USER_SERVICE), args,
|
||||
activity.getIntent().getExtras());
|
||||
if (args != null) {
|
||||
@@ -77,8 +82,8 @@ public class AccountDetailDashboardFragment extends DashboardFragment {
|
||||
mAccountType = args.getString(KEY_ACCOUNT_TYPE);
|
||||
}
|
||||
}
|
||||
mAccountSynController.init(mAccount, userHandle);
|
||||
mRemoveAccountController.init(mAccount, userHandle);
|
||||
mAccountSynController.init(mAccount, mUserHandle);
|
||||
mRemoveAccountController.init(mAccount, mUserHandle);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,7 +159,9 @@ public class AccountDetailDashboardFragment extends DashboardFragment {
|
||||
}
|
||||
final boolean display = mAccountType.equals(metadata.getString(METADATA_IA_ACCOUNT));
|
||||
if (display) {
|
||||
tile.getIntent().putExtra(EXTRA_ACCOUNT_NAME, mAccount.name);
|
||||
final Intent intent = tile.getIntent();
|
||||
intent.putExtra(EXTRA_ACCOUNT_NAME, mAccount.name);
|
||||
intent.putExtra(EXTRA_USER, mUserHandle);
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -38,6 +39,7 @@ import androidx.lifecycle.OnLifecycleEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
@@ -91,6 +93,12 @@ public class AvatarViewMixin implements LifecycleObserver {
|
||||
return;
|
||||
}
|
||||
|
||||
final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(
|
||||
mContext).getMetricsFeatureProvider();
|
||||
metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN,
|
||||
SettingsEnums.CLICK_ACCOUNT_AVATAR, SettingsEnums.SETTINGS_HOMEPAGE,
|
||||
null /* key */, Integer.MIN_VALUE /* value */);
|
||||
|
||||
// Here may have two different UI while start the activity.
|
||||
// It will display adding account UI when device has no any account.
|
||||
// It will display account information page when intent added the specified account.
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.dashboard;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_ICON_URI;
|
||||
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY;
|
||||
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY_URI;
|
||||
@@ -29,6 +31,7 @@ import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
@@ -239,7 +242,14 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
mMetricsFeatureProvider.logDashboardStartIntent(mContext, intent, sourceMetricCategory);
|
||||
activity.startActivityForResultAsUser(intent, 0, tile.userHandle.get(0));
|
||||
} else {
|
||||
ProfileSelectDialog.show(activity.getSupportFragmentManager(), tile);
|
||||
final UserHandle userHandle = intent.getParcelableExtra(EXTRA_USER);
|
||||
if (userHandle != null && tile.userHandle.contains(userHandle)) {
|
||||
mMetricsFeatureProvider.logDashboardStartIntent(
|
||||
mContext, intent, sourceMetricCategory);
|
||||
activity.startActivityForResultAsUser(intent, 0, userHandle);
|
||||
} else {
|
||||
ProfileSelectDialog.show(activity.getSupportFragmentManager(), tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ public class GameDriverEnableForAllAppsPreferenceController extends BasePreferen
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
mPreference.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,8 +99,20 @@ public class GameDriverEnableForAllAppsPreferenceController extends BasePreferen
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final boolean isChecked = (boolean) newValue;
|
||||
final int gameDriver = Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
|
||||
if (isChecked && gameDriver == GAME_DRIVER_ALL_APPS) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isChecked && (gameDriver == GAME_DRIVER_DEFAULT || gameDriver == GAME_DRIVER_OFF)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Settings.Global.putInt(mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS,
|
||||
(boolean) newValue ? GAME_DRIVER_ALL_APPS : GAME_DRIVER_DEFAULT);
|
||||
isChecked ? GAME_DRIVER_ALL_APPS : GAME_DRIVER_DEFAULT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -79,19 +79,21 @@ public class GameDriverGlobalSwitchBarController
|
||||
|
||||
@Override
|
||||
public boolean onSwitchToggled(boolean isChecked) {
|
||||
if (!isChecked) {
|
||||
Settings.Global.putInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
|
||||
final int gameDriver = Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
|
||||
if (isChecked
|
||||
&& (gameDriver == GAME_DRIVER_DEFAULT || gameDriver == GAME_DRIVER_ALL_APPS)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
|
||||
!= GAME_DRIVER_ALL_APPS) {
|
||||
Settings.Global.putInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
if (!isChecked && gameDriver == GAME_DRIVER_OFF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Settings.Global.putInt(mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS,
|
||||
isChecked ? GAME_DRIVER_DEFAULT : GAME_DRIVER_OFF);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import static android.provider.Settings.System.ADAPTIVE_SLEEP;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
@@ -26,14 +26,13 @@ import android.widget.Button;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class NightDisplayActivationPreferenceController extends TogglePreferenceController {
|
||||
|
||||
private ColorDisplayController mController;
|
||||
private ColorDisplayManager mColorDisplayManager;
|
||||
private NightDisplayTimeFormatter mTimeFormatter;
|
||||
private Button mTurnOffButton;
|
||||
private Button mTurnOnButton;
|
||||
@@ -41,14 +40,15 @@ public class NightDisplayActivationPreferenceController extends TogglePreference
|
||||
private final OnClickListener mListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mController.setActivated(!mController.isActivated());
|
||||
mColorDisplayManager.setNightDisplayActivated(!mColorDisplayManager.isNightDisplayActivated());
|
||||
updateStateInternal();
|
||||
}
|
||||
};
|
||||
|
||||
public NightDisplayActivationPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mController = new ColorDisplayController(context);
|
||||
|
||||
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
|
||||
mTimeFormatter = new NightDisplayTimeFormatter(context);
|
||||
}
|
||||
|
||||
@@ -83,17 +83,17 @@ public class NightDisplayActivationPreferenceController extends TogglePreference
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return mController.isActivated();
|
||||
return mColorDisplayManager.isNightDisplayActivated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
return mController.setActivated(isChecked);
|
||||
return mColorDisplayManager.setNightDisplayActivated(isChecked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mTimeFormatter.getAutoModeTimeSummary(mContext, mController);
|
||||
return mTimeFormatter.getAutoModeTimeSummary(mContext, mColorDisplayManager);
|
||||
}
|
||||
|
||||
private void updateStateInternal() {
|
||||
@@ -101,8 +101,8 @@ public class NightDisplayActivationPreferenceController extends TogglePreference
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean isActivated = mController.isActivated();
|
||||
final int autoMode = mController.getAutoMode();
|
||||
final boolean isActivated = mColorDisplayManager.isNightDisplayActivated();
|
||||
final int autoMode = mColorDisplayManager.getNightDisplayAutoMode();
|
||||
|
||||
String buttonText;
|
||||
if (autoMode == ColorDisplayManager.AUTO_MODE_CUSTOM_TIME) {
|
||||
@@ -110,8 +110,8 @@ public class NightDisplayActivationPreferenceController extends TogglePreference
|
||||
? R.string.night_display_activation_off_custom
|
||||
: R.string.night_display_activation_on_custom,
|
||||
mTimeFormatter.getFormattedTimeString(isActivated
|
||||
? mController.getCustomStartTime()
|
||||
: mController.getCustomEndTime()));
|
||||
? mColorDisplayManager.getNightDisplayCustomStartTime()
|
||||
: mColorDisplayManager.getNightDisplayCustomEndTime()));
|
||||
} else if (autoMode == ColorDisplayManager.AUTO_MODE_TWILIGHT) {
|
||||
buttonText = mContext.getString(isActivated
|
||||
? R.string.night_display_activation_off_twilight
|
||||
|
||||
@@ -30,11 +30,11 @@ public class NightDisplayAutoModePreferenceController extends BasePreferenceCont
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private DropDownPreference mPreference;
|
||||
private ColorDisplayManager mManager;
|
||||
private ColorDisplayManager mColorDisplayManager;
|
||||
|
||||
public NightDisplayAutoModePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mManager = context.getSystemService(ColorDisplayManager.class);
|
||||
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,11 +63,11 @@ public class NightDisplayAutoModePreferenceController extends BasePreferenceCont
|
||||
|
||||
@Override
|
||||
public final void updateState(Preference preference) {
|
||||
mPreference.setValue(String.valueOf(mManager.getNightDisplayAutoMode()));
|
||||
mPreference.setValue(String.valueOf(mColorDisplayManager.getNightDisplayAutoMode()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
return mManager.setNightDisplayAutoMode(Integer.parseInt((String) newValue));
|
||||
return mColorDisplayManager.setNightDisplayAutoMode(Integer.parseInt((String) newValue));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,18 +19,17 @@ package com.android.settings.display;
|
||||
import android.content.Context;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import androidx.preference.Preference;
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class NightDisplayCustomEndTimePreferenceController extends BasePreferenceController {
|
||||
|
||||
private ColorDisplayController mController;
|
||||
private ColorDisplayManager mColorDisplayManager;
|
||||
private NightDisplayTimeFormatter mTimeFormatter;
|
||||
|
||||
public NightDisplayCustomEndTimePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
|
||||
mController = new ColorDisplayController(context);
|
||||
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
|
||||
mTimeFormatter = new NightDisplayTimeFormatter(context);
|
||||
}
|
||||
|
||||
@@ -43,8 +42,9 @@ public class NightDisplayCustomEndTimePreferenceController extends BasePreferenc
|
||||
@Override
|
||||
public final void updateState(Preference preference) {
|
||||
preference
|
||||
.setVisible(mController.getAutoMode() == ColorDisplayManager.AUTO_MODE_CUSTOM_TIME);
|
||||
.setVisible(mColorDisplayManager.getNightDisplayAutoMode()
|
||||
== ColorDisplayManager.AUTO_MODE_CUSTOM_TIME);
|
||||
preference.setSummary(mTimeFormatter.getFormattedTimeString(
|
||||
mController.getCustomEndTime()));
|
||||
mColorDisplayManager.getNightDisplayCustomEndTime()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,18 +19,17 @@ package com.android.settings.display;
|
||||
import android.content.Context;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import androidx.preference.Preference;
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class NightDisplayCustomStartTimePreferenceController extends BasePreferenceController {
|
||||
|
||||
private ColorDisplayController mController;
|
||||
private ColorDisplayManager mColorDisplayManager;
|
||||
private NightDisplayTimeFormatter mTimeFormatter;
|
||||
|
||||
public NightDisplayCustomStartTimePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
|
||||
mController = new ColorDisplayController(context);
|
||||
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
|
||||
mTimeFormatter = new NightDisplayTimeFormatter(context);
|
||||
}
|
||||
|
||||
@@ -43,8 +42,9 @@ public class NightDisplayCustomStartTimePreferenceController extends BasePrefere
|
||||
@Override
|
||||
public final void updateState(Preference preference) {
|
||||
preference
|
||||
.setVisible(mController.getAutoMode() == ColorDisplayManager.AUTO_MODE_CUSTOM_TIME);
|
||||
.setVisible(mColorDisplayManager.getNightDisplayAutoMode()
|
||||
== ColorDisplayManager.AUTO_MODE_CUSTOM_TIME);
|
||||
preference.setSummary(mTimeFormatter.getFormattedTimeString(
|
||||
mController.getCustomStartTime()));
|
||||
mColorDisplayManager.getNightDisplayCustomStartTime()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,26 +22,24 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.core.SliderPreferenceController;
|
||||
import com.android.settings.widget.SeekBarPreference;
|
||||
|
||||
public class NightDisplayIntensityPreferenceController extends SliderPreferenceController {
|
||||
|
||||
private ColorDisplayController mController;
|
||||
private ColorDisplayManager mColorDisplayManager;
|
||||
|
||||
public NightDisplayIntensityPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mController = new ColorDisplayController(context);
|
||||
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!ColorDisplayManager.isNightDisplayAvailable(mContext)) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
} else if (!mController.isActivated()) {
|
||||
} else if (!mColorDisplayManager.isNightDisplayActivated()) {
|
||||
return DISABLED_DEPENDENT_SETTING;
|
||||
}
|
||||
return AVAILABLE;
|
||||
@@ -63,22 +61,22 @@ public class NightDisplayIntensityPreferenceController extends SliderPreferenceC
|
||||
@Override
|
||||
public final void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
preference.setEnabled(mController.isActivated());
|
||||
preference.setEnabled(mColorDisplayManager.isNightDisplayActivated());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliderPosition() {
|
||||
return convertTemperature(mController.getColorTemperature());
|
||||
return convertTemperature(mColorDisplayManager.getNightDisplayColorTemperature());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSliderPosition(int position) {
|
||||
return mController.setColorTemperature(convertTemperature(position));
|
||||
return mColorDisplayManager.setNightDisplayColorTemperature(convertTemperature(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSteps() {
|
||||
return convertTemperature(mController.getMinimumColorTemperature());
|
||||
return convertTemperature(ColorDisplayManager.getMinimumColorTemperature(mContext));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,6 +85,6 @@ public class NightDisplayIntensityPreferenceController extends SliderPreferenceC
|
||||
* adjustment status of the input.
|
||||
*/
|
||||
private int convertTemperature(int temperature) {
|
||||
return mController.getMaximumColorTemperature() - temperature;
|
||||
return ColorDisplayManager.getMaximumColorTemperature(mContext) - temperature;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.preference.SwitchPreference;
|
||||
@@ -26,12 +27,14 @@ import java.time.LocalTime;
|
||||
public class NightDisplayPreference extends SwitchPreference
|
||||
implements ColorDisplayController.Callback {
|
||||
|
||||
private ColorDisplayManager mColorDisplayManager;
|
||||
private ColorDisplayController mController;
|
||||
private NightDisplayTimeFormatter mTimeFormatter;
|
||||
|
||||
public NightDisplayPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
|
||||
mController = new ColorDisplayController(context);
|
||||
mTimeFormatter = new NightDisplayTimeFormatter(context);
|
||||
}
|
||||
@@ -76,6 +79,6 @@ public class NightDisplayPreference extends SwitchPreference
|
||||
}
|
||||
|
||||
private void updateSummary() {
|
||||
setSummary(mTimeFormatter.getAutoModeTimeSummary(getContext(), mController));
|
||||
setSummary(mTimeFormatter.getAutoModeTimeSummary(getContext(), mColorDisplayManager));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ package com.android.settings.display;
|
||||
import android.content.Context;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -37,8 +36,8 @@ public class NightDisplayPreferenceController extends AbstractPreferenceControll
|
||||
if (!isEnabled) {
|
||||
return true;
|
||||
}
|
||||
final ColorDisplayController controller = new ColorDisplayController(context);
|
||||
return controller.getAutoMode() != ColorDisplayManager.AUTO_MODE_DISABLED;
|
||||
final ColorDisplayManager manager = context.getSystemService(ColorDisplayManager.class);
|
||||
return manager.getNightDisplayAutoMode() != ColorDisplayManager.AUTO_MODE_DISABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,6 +50,7 @@ public class NightDisplaySettings extends DashboardFragment
|
||||
private static final int DIALOG_START_TIME = 0;
|
||||
private static final int DIALOG_END_TIME = 1;
|
||||
|
||||
private ColorDisplayManager mColorDisplayManager;
|
||||
private ColorDisplayController mController;
|
||||
|
||||
@Override
|
||||
@@ -57,6 +58,7 @@ public class NightDisplaySettings extends DashboardFragment
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final Context context = getContext();
|
||||
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
|
||||
mController = new ColorDisplayController(context);
|
||||
}
|
||||
|
||||
@@ -93,9 +95,9 @@ public class NightDisplaySettings extends DashboardFragment
|
||||
if (dialogId == DIALOG_START_TIME || dialogId == DIALOG_END_TIME) {
|
||||
final LocalTime initialTime;
|
||||
if (dialogId == DIALOG_START_TIME) {
|
||||
initialTime = mController.getCustomStartTime();
|
||||
initialTime = mColorDisplayManager.getNightDisplayCustomStartTime();
|
||||
} else {
|
||||
initialTime = mController.getCustomEndTime();
|
||||
initialTime = mColorDisplayManager.getNightDisplayCustomEndTime();
|
||||
}
|
||||
|
||||
final Context context = getContext();
|
||||
@@ -103,9 +105,9 @@ public class NightDisplaySettings extends DashboardFragment
|
||||
return new TimePickerDialog(context, (view, hourOfDay, minute) -> {
|
||||
final LocalTime time = LocalTime.of(hourOfDay, minute);
|
||||
if (dialogId == DIALOG_START_TIME) {
|
||||
mController.setCustomStartTime(time);
|
||||
mColorDisplayManager.setNightDisplayCustomStartTime(time);
|
||||
} else {
|
||||
mController.setCustomEndTime(time);
|
||||
mColorDisplayManager.setNightDisplayCustomEndTime(time);
|
||||
}
|
||||
}, initialTime.getHour(), initialTime.getMinute(), use24HourFormat);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.settings.display;
|
||||
import android.content.Context;
|
||||
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.R;
|
||||
|
||||
import java.text.DateFormat;
|
||||
@@ -46,22 +45,23 @@ public class NightDisplayTimeFormatter {
|
||||
return mTimeFormatter.format(c.getTime());
|
||||
}
|
||||
|
||||
public String getAutoModeTimeSummary(Context context, ColorDisplayController controller) {
|
||||
final int summaryFormatResId = controller.isActivated() ? R.string.night_display_summary_on
|
||||
: R.string.night_display_summary_off;
|
||||
return context.getString(summaryFormatResId, getAutoModeSummary(context, controller));
|
||||
public String getAutoModeTimeSummary(Context context, ColorDisplayManager manager) {
|
||||
final int summaryFormatResId =
|
||||
manager.isNightDisplayActivated() ? R.string.night_display_summary_on
|
||||
: R.string.night_display_summary_off;
|
||||
return context.getString(summaryFormatResId, getAutoModeSummary(context, manager));
|
||||
}
|
||||
|
||||
private String getAutoModeSummary(Context context, ColorDisplayController controller) {
|
||||
final boolean isActivated = controller.isActivated();
|
||||
final int autoMode = controller.getAutoMode();
|
||||
private String getAutoModeSummary(Context context, ColorDisplayManager manager) {
|
||||
final boolean isActivated = manager.isNightDisplayActivated();
|
||||
final int autoMode = manager.getNightDisplayAutoMode();
|
||||
if (autoMode == ColorDisplayManager.AUTO_MODE_CUSTOM_TIME) {
|
||||
if (isActivated) {
|
||||
return context.getString(R.string.night_display_summary_on_auto_mode_custom,
|
||||
getFormattedTimeString(controller.getCustomEndTime()));
|
||||
getFormattedTimeString(manager.getNightDisplayCustomEndTime()));
|
||||
} else {
|
||||
return context.getString(R.string.night_display_summary_off_auto_mode_custom,
|
||||
getFormattedTimeString(controller.getCustomStartTime()));
|
||||
getFormattedTimeString(manager.getNightDisplayCustomStartTime()));
|
||||
}
|
||||
} else if (autoMode == ColorDisplayManager.AUTO_MODE_TWILIGHT) {
|
||||
return context.getString(isActivated
|
||||
|
||||
@@ -128,8 +128,10 @@ public class LegacySuggestionContextualCardController implements ContextualCardC
|
||||
return;
|
||||
}
|
||||
final List<Suggestion> suggestions = mSuggestionController.getSuggestions();
|
||||
Log.d(TAG, "Loaded suggests: "
|
||||
+ suggestions == null ? "null" : String.valueOf(suggestions.size()));
|
||||
final String suggestionCount = suggestions == null
|
||||
? "null"
|
||||
: String.valueOf(suggestions.size());
|
||||
Log.d(TAG, "Loaded suggests: " + suggestionCount);
|
||||
|
||||
final List<ContextualCard> cards = new ArrayList<>();
|
||||
if (suggestions != null) {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class AppLocationPermissionPreferenceController extends
|
||||
PermissionControllerManager permController =
|
||||
mContext.getSystemService(PermissionControllerManager.class);
|
||||
permController.countPermissionApps(
|
||||
Arrays.asList(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION), false, false,
|
||||
Arrays.asList(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION), 0,
|
||||
(numApps) -> {
|
||||
mNumTotal = numApps;
|
||||
if (loadingInProgress.decrementAndGet() == 0) {
|
||||
@@ -85,7 +85,8 @@ public class AppLocationPermissionPreferenceController extends
|
||||
}, null);
|
||||
|
||||
permController.countPermissionApps(
|
||||
Collections.singletonList(ACCESS_BACKGROUND_LOCATION), true, false,
|
||||
Collections.singletonList(ACCESS_BACKGROUND_LOCATION),
|
||||
PermissionControllerManager.COUNT_ONLY_WHEN_GRANTED,
|
||||
(numApps) -> {
|
||||
mNumBackground = numApps;
|
||||
if (loadingInProgress.decrementAndGet() == 0) {
|
||||
|
||||
@@ -15,9 +15,7 @@ package com.android.settings.location;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtilsInternal.checkIfRestrictionEnforced;
|
||||
import static com.android.settingslib.Utils.updateLocationEnabled;
|
||||
import static com.android.settingslib.Utils.updateLocationMode;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -125,26 +123,6 @@ public class LocationEnabler implements LifecycleObserver, OnStart, OnStop {
|
||||
refreshLocationMode();
|
||||
}
|
||||
|
||||
void setLocationMode(int mode) {
|
||||
final int currentMode = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
|
||||
if (isRestricted()) {
|
||||
// Location toggling disabled by user restriction. Read the current location mode to
|
||||
// update the location master switch.
|
||||
if (Log.isLoggable(TAG, Log.INFO)) {
|
||||
Log.i(TAG, "Restricted user, not setting location mode");
|
||||
}
|
||||
if (mListener != null) {
|
||||
mListener.onLocationModeChanged(currentMode, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
updateLocationMode(mContext, currentMode, mode, ActivityManager.getCurrentUser(),
|
||||
Settings.Secure.LOCATION_CHANGER_SYSTEM_SETTINGS);
|
||||
refreshLocationMode();
|
||||
}
|
||||
|
||||
boolean isEnabled(int mode) {
|
||||
return mode != Settings.Secure.LOCATION_MODE_OFF && !isRestricted();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll
|
||||
return;
|
||||
}
|
||||
mContext.getSystemService(PermissionControllerManager.class).countPermissionApps(
|
||||
Arrays.asList(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION), false, false,
|
||||
Arrays.asList(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION), 0,
|
||||
(numApps) -> {
|
||||
setLocationAppCount(numApps);
|
||||
}, null);
|
||||
|
||||
@@ -97,13 +97,6 @@ public class MobileNetworkActivity extends SettingsBaseActivity {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// Set the title to the name of the subscription. If we don't have subscription info, the
|
||||
// title will just default to the label for this activity that's already specified in
|
||||
// AndroidManifest.xml.
|
||||
final SubscriptionInfo subscription = getSubscription();
|
||||
if (subscription != null) {
|
||||
setTitle(subscription.getDisplayName());
|
||||
}
|
||||
updateSubscriptions(savedInstanceState);
|
||||
}
|
||||
|
||||
@@ -136,6 +129,14 @@ public class MobileNetworkActivity extends SettingsBaseActivity {
|
||||
|
||||
@VisibleForTesting
|
||||
void updateSubscriptions(Bundle savedInstanceState) {
|
||||
// Set the title to the name of the subscription. If we don't have subscription info, the
|
||||
// title will just default to the label for this activity that's already specified in
|
||||
// AndroidManifest.xml.
|
||||
final SubscriptionInfo subscription = getSubscription();
|
||||
if (subscription != null) {
|
||||
setTitle(subscription.getDisplayName());
|
||||
}
|
||||
|
||||
mSubscriptionInfos = mSubscriptionManager.getActiveSubscriptionInfoList(true);
|
||||
|
||||
if (!FeatureFlagPersistent.isEnabled(this, FeatureFlags.NETWORK_INTERNET_V2)) {
|
||||
|
||||
@@ -28,9 +28,9 @@ import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
import com.android.settings.R;
|
||||
@@ -52,6 +52,9 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class MobileNetworkSettings extends RestrictedDashboardFragment {
|
||||
|
||||
@@ -219,6 +222,31 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2) &&
|
||||
mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
final MenuItem item = menu.add(Menu.NONE, R.id.edit_sim_name, Menu.NONE,
|
||||
R.string.mobile_network_sim_name);
|
||||
item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||
if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2) &&
|
||||
mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
if (menuItem.getItemId() == R.id.edit_sim_name) {
|
||||
RenameMobileNetworkDialogFragment.newInstance(mSubId).show(
|
||||
getFragmentManager(), RenameMobileNetworkDialogFragment.TAG);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(menuItem);
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 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 android.app.Dialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.BidiFormatter;
|
||||
import android.text.TextDirectionHeuristics;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settingslib.DeviceInfoUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
/** A dialog allowing the display name of a mobile network subscription to be changed */
|
||||
public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragment {
|
||||
public static final String TAG ="RenameMobileNetwork";
|
||||
|
||||
private static final String KEY_SUBSCRIPTION_ID = "subscription_id";
|
||||
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private int mSubId;
|
||||
private EditText mNameView;
|
||||
|
||||
public static RenameMobileNetworkDialogFragment newInstance(int subscriptionId) {
|
||||
final Bundle args = new Bundle(1);
|
||||
args.putInt(KEY_SUBSCRIPTION_ID, subscriptionId);
|
||||
final RenameMobileNetworkDialogFragment fragment = new RenameMobileNetworkDialogFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected TelephonyManager getTelephonyManager(Context context) {
|
||||
return context.getSystemService(TelephonyManager.class);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected SubscriptionManager getSubscriptionManager(Context context) {
|
||||
return context.getSystemService(SubscriptionManager.class);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected EditText getNameView() {
|
||||
return mNameView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mTelephonyManager = getTelephonyManager(context);
|
||||
mSubscriptionManager = getSubscriptionManager(context);
|
||||
mSubId = getArguments().getInt(KEY_SUBSCRIPTION_ID);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
final LayoutInflater layoutInflater = builder.getContext().getSystemService(
|
||||
LayoutInflater.class);
|
||||
final View view = layoutInflater.inflate(R.layout.dialog_mobile_network_rename, null);
|
||||
populateView(view);
|
||||
builder.setTitle(R.string.mobile_network_sim_name)
|
||||
.setView(view)
|
||||
.setPositiveButton(R.string.mobile_network_sim_name_rename, (dialog, which) -> {
|
||||
SubscriptionInfo currentInfo = mSubscriptionManager.getActiveSubscriptionInfo(
|
||||
mSubId);
|
||||
String newName = mNameView.getText().toString();
|
||||
if (currentInfo != null && !currentInfo.getDisplayName().equals(newName)) {
|
||||
mSubscriptionManager.setDisplayName(newName, mSubId);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected void populateView(View view) {
|
||||
mNameView = (EditText) view.findViewById(R.id.edittext);
|
||||
final SubscriptionInfo info = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
|
||||
if (info == null) {
|
||||
Log.w(TAG, "got null SubscriptionInfo for mSubId:" + mSubId);
|
||||
return;
|
||||
}
|
||||
final CharSequence displayName = info.getDisplayName();
|
||||
mNameView.setText(displayName);
|
||||
if (!TextUtils.isEmpty(displayName)) {
|
||||
mNameView.setSelection(displayName.length());
|
||||
}
|
||||
|
||||
final TextView operatorName = view.findViewById(R.id.operator_name_value);
|
||||
final ServiceState serviceState = mTelephonyManager.getServiceStateForSubscriber(mSubId);
|
||||
operatorName.setText(serviceState.getOperatorAlphaLong());
|
||||
|
||||
final TextView phoneNumber = view.findViewById(R.id.number_value);
|
||||
final String formattedNumber = DeviceInfoUtils.getFormattedPhoneNumber(getContext(), info);
|
||||
phoneNumber.setText(BidiFormatter.getInstance().unicodeWrap(formattedNumber,
|
||||
TextDirectionHeuristics.LTR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.MOBILE_NETWORK_RENAME_DIALOG;
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,24 @@ import android.provider.Settings;
|
||||
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
public class SilentStatusBarPreferenceController extends TogglePreferenceController {
|
||||
|
||||
private static final String KEY = "hide_silent_icons";
|
||||
private static final int MY_USER_ID = UserHandle.myUserId();
|
||||
private final NotificationBackend mBackend;
|
||||
private NotificationBackend mBackend;
|
||||
|
||||
public SilentStatusBarPreferenceController(Context context) {
|
||||
super(context, KEY);
|
||||
mBackend = new NotificationBackend();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setBackend(NotificationBackend backend) {
|
||||
mBackend = backend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return mBackend.shouldHideSilentStatusBarIcons(mContext);
|
||||
|
||||
@@ -53,7 +53,7 @@ import java.util.List;
|
||||
public class TrustAgentManager {
|
||||
|
||||
// Only allow one trust agent on the platform.
|
||||
private static final boolean ONLY_ONE_TRUST_AGENT = true;
|
||||
private static final boolean ONLY_ONE_TRUST_AGENT = false;
|
||||
|
||||
public static class TrustAgentComponentInfo {
|
||||
public ComponentName componentName;
|
||||
|
||||
@@ -322,7 +322,7 @@ public class EntityHeaderController {
|
||||
Utils.getColorAttrDefaultColor(activity, android.R.attr.colorPrimaryDark)));
|
||||
actionBar.setElevation(0);
|
||||
if (mRecyclerView != null && mLifecycle != null) {
|
||||
ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
|
||||
ActionBarShadowController.attachToView(mActivity, mLifecycle, mRecyclerView);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
@@ -366,9 +366,8 @@ public class WifiConfigController implements TextWatcher,
|
||||
suggestionOrSpecifierPackageName = config.creatorName;
|
||||
}
|
||||
String summary = AccessPoint.getSummary(
|
||||
mConfigUi.getContext(), state, isEphemeral,
|
||||
suggestionOrSpecifierPackageName,
|
||||
providerFriendlyName);
|
||||
mConfigUi.getContext(), /* ssid */ null, state, isEphemeral,
|
||||
suggestionOrSpecifierPackageName);
|
||||
addRow(group, R.string.wifi_status, summary);
|
||||
}
|
||||
|
||||
|
||||
@@ -562,24 +562,24 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
* Bypass dialog and connect to unsecured networks, or previously connected saved
|
||||
* networks, or Passpoint provided networks.
|
||||
*/
|
||||
WifiConfiguration config = mSelectedAccessPoint.getConfig();
|
||||
if (mSelectedAccessPoint.isOsuProvider()) {
|
||||
mSelectedAccessPoint.startOsuProvisioning();
|
||||
mClickedConnect = true;
|
||||
} else if ((mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) ||
|
||||
(mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_OWE)) {
|
||||
mSelectedAccessPoint.generateOpenNetworkConfig();
|
||||
connect(mSelectedAccessPoint.getConfig(), mSelectedAccessPoint.isSaved());
|
||||
} else if (mSelectedAccessPoint.isSaved() && config != null
|
||||
&& config.getNetworkSelectionStatus() != null
|
||||
&& config.getNetworkSelectionStatus().getHasEverConnected()) {
|
||||
connect(config, true /* isSavedNetwork */);
|
||||
} else if (mSelectedAccessPoint.isPasspoint()) {
|
||||
// Access point provided by an installed Passpoint provider, connect using
|
||||
// the associated config.
|
||||
connect(config, true /* isSavedNetwork */);
|
||||
} else {
|
||||
showDialog(mSelectedAccessPoint, WifiConfigUiBase.MODE_CONNECT);
|
||||
switch (WifiUtils.getConnectingType(mSelectedAccessPoint)) {
|
||||
case WifiUtils.CONNECT_TYPE_OSU_PROVISION:
|
||||
mSelectedAccessPoint.startOsuProvisioning();
|
||||
mClickedConnect = true;
|
||||
break;
|
||||
|
||||
case WifiUtils.CONNECT_TYPE_OPEN_NETWORK:
|
||||
mSelectedAccessPoint.generateOpenNetworkConfig();
|
||||
connect(mSelectedAccessPoint.getConfig(), mSelectedAccessPoint.isSaved());
|
||||
break;
|
||||
|
||||
case WifiUtils.CONNECT_TYPE_SAVED_NETWORK:
|
||||
connect(mSelectedAccessPoint.getConfig(), true /* isSavedNetwork */);
|
||||
break;
|
||||
|
||||
default:
|
||||
showDialog(mSelectedAccessPoint, WifiConfigUiBase.MODE_CONNECT);
|
||||
break;
|
||||
}
|
||||
} else if (preference == mAddPreference) {
|
||||
onAddNetworkPressed();
|
||||
|
||||
@@ -299,7 +299,8 @@ public class WifiStatusTest extends Activity {
|
||||
WifiInfo info = mWifiManager.getConnectionInfo();
|
||||
String summary = AccessPoint.getSummary(this, info.getSSID(),
|
||||
networkInfo.getDetailedState(),
|
||||
info.getNetworkId() == WifiConfiguration.INVALID_NETWORK_ID, null, null);
|
||||
info.getNetworkId() == WifiConfiguration.INVALID_NETWORK_ID,
|
||||
/* suggestionOrSpecifierPackageName */ null);
|
||||
mNetworkState.setText(summary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,4 +253,33 @@ public class WifiUtils {
|
||||
|
||||
return AccessPoint.SECURITY_NONE;
|
||||
}
|
||||
|
||||
|
||||
public static final int CONNECT_TYPE_OTHERS = 0;
|
||||
public static final int CONNECT_TYPE_OPEN_NETWORK = 1;
|
||||
public static final int CONNECT_TYPE_SAVED_NETWORK = 2;
|
||||
public static final int CONNECT_TYPE_OSU_PROVISION = 3;
|
||||
|
||||
/**
|
||||
* Gets the connecting type of {@link AccessPoint}.
|
||||
*/
|
||||
public static int getConnectingType(AccessPoint accessPoint) {
|
||||
final WifiConfiguration config = accessPoint.getConfig();
|
||||
if (accessPoint.isOsuProvider()) {
|
||||
return CONNECT_TYPE_OSU_PROVISION;
|
||||
} else if ((accessPoint.getSecurity() == AccessPoint.SECURITY_NONE) ||
|
||||
(accessPoint.getSecurity() == AccessPoint.SECURITY_OWE)) {
|
||||
return CONNECT_TYPE_OPEN_NETWORK;
|
||||
} else if (accessPoint.isSaved() && config != null
|
||||
&& config.getNetworkSelectionStatus() != null
|
||||
&& config.getNetworkSelectionStatus().getHasEverConnected()) {
|
||||
return CONNECT_TYPE_SAVED_NETWORK;
|
||||
} else if (accessPoint.isPasspoint()) {
|
||||
// Access point provided by an installed Passpoint provider, connect using
|
||||
// the associated config.
|
||||
return CONNECT_TYPE_SAVED_NETWORK;
|
||||
} else {
|
||||
return CONNECT_TYPE_OTHERS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.wifi.slice;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.wifi.WifiDialogActivity;
|
||||
import com.android.settings.wifi.WifiUtils;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
|
||||
/**
|
||||
* This activity helps connect to the Wi-Fi network which is open or saved
|
||||
*/
|
||||
public class ConnectToWifiHandler extends Activity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final Bundle accessPointState = getIntent().getBundleExtra(
|
||||
WifiDialogActivity.KEY_ACCESS_POINT_STATE);
|
||||
|
||||
if (accessPointState != null) {
|
||||
connect(new AccessPoint(this, accessPointState));
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void connect(AccessPoint accessPoint) {
|
||||
switch (WifiUtils.getConnectingType(accessPoint)) {
|
||||
case WifiUtils.CONNECT_TYPE_OSU_PROVISION:
|
||||
accessPoint.startOsuProvisioning();
|
||||
break;
|
||||
|
||||
case WifiUtils.CONNECT_TYPE_OPEN_NETWORK:
|
||||
accessPoint.generateOpenNetworkConfig();
|
||||
|
||||
case WifiUtils.CONNECT_TYPE_SAVED_NETWORK:
|
||||
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
||||
wifiManager.connect(accessPoint.getConfig(), null /* listener */);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ import com.android.settings.slices.SliceBackgroundWorker;
|
||||
import com.android.settings.slices.SliceBuilderUtils;
|
||||
import com.android.settings.wifi.WifiDialogActivity;
|
||||
import com.android.settings.wifi.WifiSettings;
|
||||
import com.android.settings.wifi.WifiUtils;
|
||||
import com.android.settings.wifi.details.WifiNetworkDetailsFragment;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.settingslib.wifi.WifiTracker;
|
||||
@@ -176,6 +177,9 @@ public class WifiSlice implements CustomSliceable {
|
||||
.setArguments(extras)
|
||||
.setSourceMetricsCategory(SettingsEnums.WIFI)
|
||||
.toIntent();
|
||||
} else if (WifiUtils.getConnectingType(accessPoint) != WifiUtils.CONNECT_TYPE_OTHERS) {
|
||||
intent = new Intent(mContext, ConnectToWifiHandler.class);
|
||||
intent.putExtra(WifiDialogActivity.KEY_ACCESS_POINT_STATE, extras);
|
||||
} else {
|
||||
intent = new Intent(mContext, WifiDialogActivity.class);
|
||||
intent.putExtra(WifiDialogActivity.KEY_ACCESS_POINT_STATE, extras);
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_KEYHINT;
|
||||
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_TITLE;
|
||||
|
||||
@@ -160,6 +162,20 @@ public class AccountDetailDashboardFragmentTest {
|
||||
assertThat(intent.getStringExtra("extra.accountName")).isEqualTo("name1@abc.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayTile_shouldAddUserHandleToTileIntent() {
|
||||
mFragment.mUserHandle = new UserHandle(1);
|
||||
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
|
||||
mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
|
||||
mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
|
||||
|
||||
mFragment.displayTile(tile);
|
||||
|
||||
final UserHandle userHandle = tile.getIntent().getParcelableExtra(EXTRA_USER);
|
||||
assertThat(userHandle.getIdentifier()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_accountMissing_shouldFinish() {
|
||||
ShadowUserManager userManager =
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.dashboard;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
import static com.android.settingslib.drawer.TileUtils.META_DATA_KEY_ORDER;
|
||||
import static com.android.settingslib.drawer.TileUtils.META_DATA_KEY_PROFILE;
|
||||
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_KEYHINT;
|
||||
@@ -67,6 +69,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
@@ -412,4 +415,44 @@ public class DashboardFeatureProviderImplTest {
|
||||
.startActivityForResult(any(Intent.class), eq(0));
|
||||
verify(mActivity, never()).getSupportFragmentManager();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void openTileIntent_profileSelectionDialog_validUserHandleShouldNotShow() {
|
||||
final int userId = 10;
|
||||
ShadowUserManager.getShadow().addUser(userId, "Someone", 0);
|
||||
|
||||
final UserHandle userHandle = new UserHandle(userId);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.getIntent().putExtra(EXTRA_USER, userHandle);
|
||||
final ArrayList<UserHandle> handles = new ArrayList<>();
|
||||
handles.add(new UserHandle(0));
|
||||
handles.add(userHandle);
|
||||
tile.userHandle = handles;
|
||||
|
||||
mImpl.openTileIntent(mActivity, tile);
|
||||
|
||||
final ArgumentCaptor<UserHandle> argument = ArgumentCaptor.forClass(UserHandle.class);
|
||||
verify(mActivity)
|
||||
.startActivityForResultAsUser(any(Intent.class), anyInt(), argument.capture());
|
||||
assertThat(argument.getValue().getIdentifier()).isEqualTo(userId);
|
||||
verify(mActivity, never()).getSupportFragmentManager();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void openTileIntent_profileSelectionDialog_invalidUserHandleShouldShow() {
|
||||
ShadowUserManager.getShadow().addUser(10, "Someone", 0);
|
||||
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.getIntent().putExtra(EXTRA_USER, new UserHandle(30));
|
||||
final ArrayList<UserHandle> handles = new ArrayList<>();
|
||||
handles.add(new UserHandle(0));
|
||||
handles.add(new UserHandle(10));
|
||||
tile.userHandle = handles;
|
||||
|
||||
mImpl.openTileIntent(mActivity, tile);
|
||||
|
||||
verify(mActivity, never())
|
||||
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
|
||||
verify(mActivity).getSupportFragmentManager();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_U
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
@@ -61,11 +62,14 @@ public class GameDriverEnableForAllAppsPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mResolver = mContext.getContentResolver();
|
||||
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
|
||||
mController = new GameDriverEnableForAllAppsPreferenceController(mContext, "testKey");
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,7 +155,7 @@ public class GameDriverEnableForAllAppsPreferenceControllerTest {
|
||||
mController.onPreferenceChange(mPreference, true);
|
||||
|
||||
assertThat(Settings.Global.getInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
|
||||
.isEqualTo(GAME_DRIVER_ALL_APPS);
|
||||
}
|
||||
|
||||
@@ -162,7 +166,7 @@ public class GameDriverEnableForAllAppsPreferenceControllerTest {
|
||||
mController.onPreferenceChange(mPreference, false);
|
||||
|
||||
assertThat(Settings.Global.getInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
|
||||
.isEqualTo(GAME_DRIVER_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.settings.homepage.contextualcards.legacysuggestion;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -84,8 +85,10 @@ public class LegacySuggestionContextualCardControllerTest {
|
||||
|
||||
@Test
|
||||
public void onServiceConnected_shouldLoadSuggestion() {
|
||||
when(mSuggestionController.getSuggestions()).thenReturn(null);
|
||||
mController.mSuggestionController = mSuggestionController;
|
||||
mController.setCardUpdateListener(mCardUpdateListener);
|
||||
|
||||
mController.onServiceConnected();
|
||||
|
||||
verify(mSuggestionController).getSuggestions();
|
||||
|
||||
@@ -141,57 +141,6 @@ public class LocationEnablerTest {
|
||||
verify(mListener).onLocationModeChanged(anyInt(), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setLocationMode_restricted_shouldSetCurrentMode() {
|
||||
when(mUserManager.hasUserRestriction(anyString())).thenReturn(true);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
|
||||
|
||||
mEnabler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
||||
|
||||
verify(mListener).onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setLocationMode_notRestricted_shouldUpdateSecureSettings() {
|
||||
when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
|
||||
|
||||
mEnabler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
||||
|
||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING))
|
||||
.isEqualTo(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setLocationMode_notRestricted_shouldRefreshLocation() {
|
||||
when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
|
||||
|
||||
mEnabler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
||||
|
||||
verify(mEnabler).refreshLocationMode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setLocationMode_notRestricted_shouldBroadcastUpdateAndSetChanger() {
|
||||
when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
|
||||
mEnabler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
||||
|
||||
verify(mContext).sendBroadcastAsUser(
|
||||
argThat(actionMatches(LocationManager.MODE_CHANGING_ACTION)),
|
||||
eq(UserHandle.of(ActivityManager.getCurrentUser())),
|
||||
eq(WRITE_SECURE_SETTINGS));
|
||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_CHANGER, Settings.Secure.LOCATION_CHANGER_UNKNOWN))
|
||||
.isEqualTo(Settings.Secure.LOCATION_CHANGER_SYSTEM_SETTINGS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setLocationEnabled_notRestricted_shouldRefreshLocation() {
|
||||
when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
|
||||
|
||||
@@ -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.network.telephony;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
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.DialogInterface;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowAlertDialogCompat.class)
|
||||
public class RenameMobileNetworkDialogFragmentTest {
|
||||
@Mock
|
||||
private TelephonyManager mTelephonyMgr;
|
||||
@Mock
|
||||
private SubscriptionManager mSubscriptionMgr;
|
||||
@Mock
|
||||
private SubscriptionInfo mSubscriptionInfo;
|
||||
|
||||
private FragmentActivity mActivity;
|
||||
private RenameMobileNetworkDialogFragment mFragment;
|
||||
private int mSubscriptionId = 1234;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
|
||||
|
||||
when(mSubscriptionInfo.getSubscriptionId()).thenReturn(mSubscriptionId);
|
||||
when(mSubscriptionInfo.getDisplayName()).thenReturn("test");
|
||||
|
||||
mFragment = spy(RenameMobileNetworkDialogFragment.newInstance(mSubscriptionId));
|
||||
doReturn(mTelephonyMgr).when(mFragment).getTelephonyManager(any());
|
||||
doReturn(mSubscriptionMgr).when(mFragment).getSubscriptionManager(any());
|
||||
|
||||
final ServiceState serviceState = mock(ServiceState.class);
|
||||
when(serviceState.getOperatorAlphaLong()).thenReturn("fake carrier name");
|
||||
when(mTelephonyMgr.getServiceStateForSubscriber(mSubscriptionId)).thenReturn(serviceState);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialog_subscriptionMissing_noCrash() {
|
||||
final AlertDialog dialog = startDialog();
|
||||
final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
|
||||
assertThat(negativeButton).isNotNull();
|
||||
negativeButton.performClick();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialog_cancelButtonClicked_setDisplayNameNotCalled() {
|
||||
when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
|
||||
mSubscriptionInfo);
|
||||
final AlertDialog dialog = startDialog();
|
||||
final EditText nameView = mFragment.getNameView();
|
||||
nameView.setText("test2");
|
||||
|
||||
final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
|
||||
negativeButton.performClick();
|
||||
|
||||
verify(mSubscriptionMgr, never()).setDisplayName(anyString(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialog_renameButtonClicked_setDisplayNameCalled() {
|
||||
when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
|
||||
mSubscriptionInfo);
|
||||
|
||||
final AlertDialog dialog = startDialog();
|
||||
final EditText nameView = mFragment.getNameView();
|
||||
nameView.setText("test2");
|
||||
|
||||
final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
positiveButton.performClick();
|
||||
|
||||
final ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mSubscriptionMgr).setDisplayName(captor.capture(), eq(mSubscriptionId));
|
||||
assertThat(captor.getValue()).isEqualTo("test2");
|
||||
}
|
||||
|
||||
/** Helper method to start the dialog */
|
||||
private AlertDialog startDialog() {
|
||||
mFragment.show(mActivity.getSupportFragmentManager(), null);
|
||||
return ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,6 @@ public class SilentStatusBarPreferenceControllerTest {
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
private Context mContext;
|
||||
private SilentStatusBarPreferenceController mController;
|
||||
private Preference mPreference;
|
||||
@@ -57,8 +56,8 @@ public class SilentStatusBarPreferenceControllerTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mController = new SilentStatusBarPreferenceController(mContext);
|
||||
mController.setBackend(mBackend);
|
||||
mPreference = new Preference(mContext);
|
||||
mPreference.setKey(mController.getPreferenceKey());
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
@@ -83,7 +82,7 @@ public class SilentStatusBarPreferenceControllerTest {
|
||||
when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(false);
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
/**
|
||||
|
||||
@Test
|
||||
public void isChecked_settingIsOn_true() {
|
||||
when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(true);
|
||||
@@ -93,18 +92,13 @@ public class SilentStatusBarPreferenceControllerTest {
|
||||
@Test
|
||||
public void onPreferenceChange_on() {
|
||||
mController.onPreferenceChange(mPreference, true);
|
||||
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
verify(mBackend).setHideSilentStatusIcons(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_off() {
|
||||
mController.onPreferenceChange(mPreference, false);
|
||||
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
verify(mBackend).setHideSilentStatusIcons(false);
|
||||
}
|
||||
**/
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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.wifi.slice;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
|
||||
|
||||
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
|
||||
import com.android.settings.testutils.shadow.ShadowWifiManager;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {
|
||||
ShadowConnectivityManager.class,
|
||||
ShadowWifiManager.class,
|
||||
})
|
||||
public class ConnectToWifiHandlerTest {
|
||||
|
||||
private static final String AP1_SSID = "\"ap1\"";
|
||||
private ConnectToWifiHandler mHandler;
|
||||
private WifiConfiguration mWifiConfig;
|
||||
@Mock
|
||||
private AccessPoint mAccessPoint;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mHandler = Robolectric.setupActivity(ConnectToWifiHandler.class);
|
||||
mWifiConfig = new WifiConfiguration();
|
||||
mWifiConfig.SSID = AP1_SSID;
|
||||
doReturn(mWifiConfig).when(mAccessPoint).getConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void connect_shouldConnectToUnsavedOpenNetwork() {
|
||||
when(mAccessPoint.isSaved()).thenReturn(false);
|
||||
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_NONE);
|
||||
|
||||
mHandler.connect(mAccessPoint);
|
||||
|
||||
assertThat(ShadowWifiManager.get().savedWifiConfig.SSID).isEqualTo(AP1_SSID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void connect_shouldStartOsuProvisioning() {
|
||||
when(mAccessPoint.isSaved()).thenReturn(false);
|
||||
when(mAccessPoint.isOsuProvider()).thenReturn(true);
|
||||
|
||||
mHandler.connect(mAccessPoint);
|
||||
|
||||
verify(mAccessPoint).startOsuProvisioning();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void connect_shouldConnectWithPasspointProvider() {
|
||||
when(mAccessPoint.isSaved()).thenReturn(false);
|
||||
when(mAccessPoint.isPasspoint()).thenReturn(true);
|
||||
|
||||
mHandler.connect(mAccessPoint);
|
||||
|
||||
assertThat(ShadowWifiManager.get().savedWifiConfig.SSID).isEqualTo(AP1_SSID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void connect_shouldConnectToSavedSecuredNetwork() {
|
||||
when(mAccessPoint.isSaved()).thenReturn(true);
|
||||
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_PSK);
|
||||
final NetworkSelectionStatus status = new NetworkSelectionStatus();
|
||||
status.setHasEverConnected(true);
|
||||
mWifiConfig.setNetworkSelectionStatus(status);
|
||||
|
||||
mHandler.connect(mAccessPoint);
|
||||
|
||||
assertThat(ShadowWifiManager.get().savedWifiConfig.SSID).isEqualTo(AP1_SSID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void connect_shouldNotConnectToUnsavedSecuredNetwork() {
|
||||
when(mAccessPoint.isSaved()).thenReturn(false);
|
||||
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_PSK);
|
||||
|
||||
mHandler.connect(mAccessPoint);
|
||||
|
||||
assertThat(ShadowWifiManager.get().savedWifiConfig).isNull();
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class LocationSettingsTests extends InstrumentationTestCase {
|
||||
public void testLocationDeviceOnlyMode() throws Exception {
|
||||
// Changing the value from default before testing the toggle to Device only mode
|
||||
Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_ON);
|
||||
dismissAlertDialogs();
|
||||
Thread.sleep(TIMEOUT);
|
||||
verifyLocationSettingsMode(Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
|
||||
@@ -114,7 +114,7 @@ public class LocationSettingsTests extends InstrumentationTestCase {
|
||||
Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
|
||||
Thread.sleep(TIMEOUT);
|
||||
verifyLocationSettingsMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
||||
verifyLocationSettingsMode(Settings.Secure.LOCATION_MODE_ON);
|
||||
}
|
||||
|
||||
@MediumTest
|
||||
@@ -145,7 +145,7 @@ public class LocationSettingsTests extends InstrumentationTestCase {
|
||||
private void verifyLocationSettingsMode(int mode) throws Exception {
|
||||
int modeIntValue = 1;
|
||||
String textMode = "Device only";
|
||||
if (mode == Settings.Secure.LOCATION_MODE_HIGH_ACCURACY) {
|
||||
if (mode == Settings.Secure.LOCATION_MODE_ON) {
|
||||
modeIntValue = 3;
|
||||
textMode = "High accuracy";
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class LocationSettingsTests extends InstrumentationTestCase {
|
||||
dismissAlertDialogs();
|
||||
mDevice.wait(Until.findObject(By.desc("Navigate up")), TIMEOUT).click();
|
||||
Thread.sleep(TIMEOUT);
|
||||
if (mode == Settings.Secure.LOCATION_MODE_HIGH_ACCURACY ||
|
||||
if (mode == Settings.Secure.LOCATION_MODE_ON ||
|
||||
mode == Settings.Secure.LOCATION_MODE_BATTERY_SAVING) {
|
||||
dismissAlertDialogs();
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class LocationSettingsTests extends InstrumentationTestCase {
|
||||
}
|
||||
else {
|
||||
Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_ON);
|
||||
}
|
||||
dismissAlertDialogs();
|
||||
// Load location settings
|
||||
|
||||
Reference in New Issue
Block a user