Snap for 6388478 from 11ab1464c4 to mainline-release

Change-Id: Ibe05a2dfd9dc86fe1ddbaacfabcdf46305d102f5
This commit is contained in:
android-build-team Robot
2020-04-12 07:09:51 +00:00
31 changed files with 524 additions and 91 deletions

View File

@@ -3107,6 +3107,19 @@
android:value="true"/>
</service>
<service
android:name=".development.qstile.DevelopmentTiles$WirelessDebugging"
android:label="@string/enable_adb_wireless"
android:icon="@drawable/tile_icon_debugging_wireless"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:enabled="false">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
<meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
<activity
android:name=".HelpTrampoline"
android:exported="true"

View File

@@ -0,0 +1,28 @@
<!--
Copyright (C) 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M19,10.3L19,16A7,7 0,0 1,5 16L5,10.3ZM7.5,14.5l0.8,0.8a5.3,5.3 0,0 1,7.4 0l0.8,-0.8A6.3,6.3 0,0 0,7.5 14.5ZM10.8,17.8L12,19l1.2,-1.2A1.6,1.6 0,0 0,10.8 17.8ZM9.1,16.1l0.9,0.9a2.7,2.7 0,0 1,4 0l0.9,-0.9A4.3,4.3 0,0 0,9.1 16.1Z"/>
<path
android:fillColor="#FFFFFFFF"
android:pathData="M15.6,3.9l1.1,-2c0.1,-0.2 0.1,-0.4 -0.1,-0.5a0.5,0.5 0,0 0,-0.6 0.1L14.8,3.6a6.8,6.8 0,0 0,-5.6 0L8,1.5a0.5,0.5 0,0 0,-0.6 -0.1c-0.2,0.1 -0.2,0.3 -0.1,0.5l1.1,2A7.1,7.1 0,0 0,5 9.3L19,9.3A7.1,7.1 0,0 0,15.6 3.9ZM8.8,7.6A0.9,0.9 0,0 1,8 6.8,0.9 0.9,0 0,1 8.8,6a0.8,0.8 0,1 1,0 1.6ZM15.2,7.6a0.8,0.8 0,1 1,0 -1.6,0.9 0.9,0 0,1 0.8,0.8A0.9,0.9 0,0 1,15.2 7.6Z"/>
</vector>

View File

@@ -16,6 +16,7 @@
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay">
@@ -24,8 +25,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingEnd="24dp"
android:paddingStart="24dp">
android:padding="24dp">
<TextView
style="@style/AccessibilityDialogDescription"

View File

@@ -17,6 +17,7 @@
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay">
@@ -38,4 +39,4 @@
</LinearLayout>
</ScrollView>
</ScrollView>

View File

@@ -16,6 +16,7 @@
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay">

View File

@@ -27,12 +27,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_marginEnd="@dimen/description_margin_sides"
android:layout_marginTop="@dimen/zen_mode_settings_button_margin_vertical"/>
<Button
android:id="@+id/zen_mode_settings_turn_on_button"
style="@style/ActionPrimaryButton"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_marginEnd="@dimen/description_margin_sides"
android:layout_marginTop="@dimen/zen_mode_settings_button_margin_vertical"
android:layout_marginBottom="@dimen/zen_mode_settings_button_margin_vertical"
android:text="@string/zen_mode_button_turn_on"
@@ -44,6 +46,7 @@
android:id="@+id/zen_mode_settings_turn_off_button"
style="@style/ActionSecondaryButton"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_marginEnd="@dimen/description_margin_sides"
android:layout_marginTop="@dimen/zen_mode_settings_button_margin_vertical"
android:layout_marginBottom="@dimen/zen_mode_settings_button_margin_vertical"
android:text="@string/zen_mode_button_turn_off"

View File

@@ -29,6 +29,7 @@ import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
@@ -76,7 +77,7 @@ public class AccessibilityEditDialogUtils {
final AlertDialog alertDialog = createDialog(context, DialogType.EDIT_SHORTCUT_GENERIC,
dialogTitle, listener);
alertDialog.show();
setScrollIndicators(alertDialog);
return alertDialog;
}
@@ -93,7 +94,7 @@ public class AccessibilityEditDialogUtils {
final AlertDialog alertDialog = createDialog(context,
DialogType.EDIT_SHORTCUT_MAGNIFICATION, dialogTitle, listener);
alertDialog.show();
setScrollIndicators(alertDialog);
return alertDialog;
}
@@ -110,7 +111,7 @@ public class AccessibilityEditDialogUtils {
final AlertDialog alertDialog = createDialog(context,
DialogType.EDIT_MAGNIFICATION_MODE, dialogTitle, listener);
alertDialog.show();
setScrollIndicators(alertDialog);
return alertDialog;
}
@@ -128,6 +129,17 @@ public class AccessibilityEditDialogUtils {
return alertDialog;
}
/**
* Sets the scroll indicators for dialog view. The indicators appears while content view is
* out of vision for vertical scrolling.
*/
private static void setScrollIndicators(AlertDialog dialog) {
final ScrollView scrollView = dialog.findViewById(R.id.container_layout);
scrollView.setScrollIndicators(
View.SCROLL_INDICATOR_TOP | View.SCROLL_INDICATOR_BOTTOM,
View.SCROLL_INDICATOR_TOP | View.SCROLL_INDICATOR_BOTTOM);
}
/**
* Get a content View for the edit shortcut dialog.
*

View File

@@ -20,9 +20,6 @@ import android.content.Context;
import android.os.UserHandle;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import com.android.settings.core.TogglePreferenceController;
/** Controller that shows the magnification enable mode summary. */

View File

@@ -54,6 +54,7 @@ public class MagnificationGesturesPreferenceController extends TogglePreferenceC
populateMagnificationGesturesPreferenceExtras(extras, mContext);
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED, isChecked());
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mIsFromSUW);
return true;
}
return false;
}

View File

@@ -59,6 +59,7 @@ public class MagnificationNavbarPreferenceController extends TogglePreferenceCon
mContext.getText(R.string.accessibility_screen_magnification_navbar_summary));
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED, isChecked());
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mIsFromSUW);
return true;
}
return false;
}

View File

@@ -42,6 +42,7 @@ import android.view.accessibility.AccessibilityManager.TouchExplorationStateChan
import android.widget.CheckBox;
import android.widget.ImageView;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
@@ -242,7 +243,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
case DialogEnums.EDIT_SHORTCUT:
final CharSequence dialogTitle = getPrefContext().getString(
R.string.accessibility_shortcut_title, mPackageName);
Dialog dialog = AccessibilityEditDialogUtils.showEditShortcutDialog(
final AlertDialog dialog = AccessibilityEditDialogUtils.showEditShortcutDialog(
getPrefContext(), dialogTitle, this::callOnAlertDialogCheckboxClicked);
initializeDialogCheckBox(dialog);
return dialog;

View File

@@ -80,6 +80,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
private static final int ORDER_NEXT_TO_LAST = 1001;
private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
private static final String PREF_KEY_ADD_ACCOUNT = "add_account";
private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
@@ -225,11 +226,13 @@ public class AccountPreferenceController extends AbstractPreferenceController
@Override
public boolean onPreferenceClick(Preference preference) {
final int metricsCategory = mFragment.getMetricsCategory();
// Check the preference
final int count = mProfiles.size();
for (int i = 0; i < count; i++) {
ProfileData profileData = mProfiles.valueAt(i);
if (preference == profileData.addAccountPreference) {
mMetricsFeatureProvider.logClickedPreference(preference, metricsCategory);
Intent intent = new Intent(ACTION_ADD_ACCOUNT);
intent.putExtra(EXTRA_USER, profileData.userInfo.getUserHandle());
intent.putExtra(EXTRA_AUTHORITIES, mAuthorities);
@@ -237,16 +240,18 @@ public class AccountPreferenceController extends AbstractPreferenceController
return true;
}
if (preference == profileData.removeWorkProfilePreference) {
mMetricsFeatureProvider.logClickedPreference(preference, metricsCategory);
final int userId = profileData.userInfo.id;
RemoveUserFragment.newInstance(userId).show(mFragment.getFragmentManager(),
"removeUser");
return true;
}
if (preference == profileData.managedProfilePreference) {
mMetricsFeatureProvider.logClickedPreference(preference, metricsCategory);
Bundle arguments = new Bundle();
arguments.putParcelable(Intent.EXTRA_USER, profileData.userInfo.getUserHandle());
new SubSettingLauncher(mContext)
.setSourceMetricsCategory(mFragment.getMetricsCategory())
.setSourceMetricsCategory(metricsCategory)
.setDestination(ManagedProfileSettings.class.getName())
.setTitleRes(R.string.managed_profile_settings_title)
.setArguments(arguments)
@@ -360,6 +365,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
private RestrictedPreference newAddAccountPreference() {
RestrictedPreference preference =
new RestrictedPreference(mFragment.getPreferenceManager().getContext());
preference.setKey(PREF_KEY_ADD_ACCOUNT);
preference.setTitle(R.string.add_account_label);
preference.setIcon(R.drawable.ic_add_24dp);
preference.setOnPreferenceClickListener(this);

View File

@@ -40,10 +40,12 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.widget.LayoutPreference;
import java.io.IOException;
@@ -53,20 +55,23 @@ public class RemoveAccountPreferenceController extends AbstractPreferenceControl
private static final String KEY_REMOVE_ACCOUNT = "remove_account";
private final MetricsFeatureProvider mMetricsFeatureProvider;
private Account mAccount;
private Fragment mParentFragment;
private UserHandle mUserHandle;
private LayoutPreference mRemoveAccountPreference;
public RemoveAccountPreferenceController(Context context, Fragment parent) {
super(context);
mParentFragment = parent;
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final LayoutPreference removeAccountPreference = screen.findPreference(KEY_REMOVE_ACCOUNT);
Button removeAccountButton = (Button) removeAccountPreference.findViewById(R.id.button);
mRemoveAccountPreference = screen.findPreference(KEY_REMOVE_ACCOUNT);
final Button removeAccountButton = mRemoveAccountPreference.findViewById(R.id.button);
removeAccountButton.setOnClickListener(this);
}
@@ -82,6 +87,8 @@ public class RemoveAccountPreferenceController extends AbstractPreferenceControl
@Override
public void onClick(View v) {
mMetricsFeatureProvider.logClickedPreference(mRemoveAccountPreference,
mMetricsFeatureProvider.getMetricsCategory(mParentFragment));
if (mUserHandle != null) {
final EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfRestrictionEnforced(
mContext, UserManager.DISALLOW_MODIFY_ACCOUNTS, mUserHandle.getIdentifier());

View File

@@ -173,6 +173,13 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
checkUiBlocker(mControllers);
refreshAllPreferences(getLogTag());
mControllers.stream()
.map(controller -> (Preference) findPreference(controller.getPreferenceKey()))
.filter(Objects::nonNull)
.forEach(preference -> {
// Give all controllers a chance to handle click.
preference.getExtras().putInt(CATEGORY, getMetricsCategory());
});
}
@Override
@@ -211,8 +218,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
public boolean onPreferenceTreeClick(Preference preference) {
final Collection<List<AbstractPreferenceController>> controllers =
mPreferenceControllers.values();
// Give all controllers a chance to handle click.
preference.getExtras().putInt(CATEGORY, getMetricsCategory());
for (List<AbstractPreferenceController> controllerList : controllers) {
for (AbstractPreferenceController controller : controllerList) {
if (controller.handlePreferenceTreeClick(preference)) {

View File

@@ -135,7 +135,10 @@ public class WirelessDebuggingPreferenceController extends DeveloperOptionsPrefe
((MasterSwitchPreference) preference).setChecked(enabled);
}
static boolean isWifiConnected(Context context) {
/**
* Returns true if connected to Wi-Fi network.
*/
public static boolean isWifiConnected(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(
Context.CONNECTIVITY_SERVICE);
if (cm != null) {

View File

@@ -16,13 +16,21 @@
package com.android.settings.development.qstile;
import static com.android.settings.development.AdbPreferenceController.ADB_SETTING_OFF;
import static com.android.settings.development.AdbPreferenceController.ADB_SETTING_ON;
import android.app.KeyguardManager;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.ContentObserver;
import android.hardware.SensorPrivacyManager;
import android.app.KeyguardManager;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -41,6 +49,8 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.app.LocalePicker;
import com.android.internal.statusbar.IStatusBarService;
import com.android.settings.R;
import com.android.settings.development.WirelessDebuggingPreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
@@ -349,4 +359,77 @@ public abstract class DevelopmentTiles extends TileService {
mSensorPrivacyManager.setSensorPrivacy(isEnabled);
}
}
/**
* Tile to control the "Wireless debugging" developer setting
*/
public static class WirelessDebugging extends DevelopmentTiles {
private Context mContext;
private KeyguardManager mKeyguardManager;
private Toast mToast;
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final ContentObserver mSettingsObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange, Uri uri) {
refresh();
}
};
@Override
public void onCreate() {
super.onCreate();
mContext = getApplicationContext();
mKeyguardManager = (KeyguardManager) mContext.getSystemService(
Context.KEYGUARD_SERVICE);
mToast = Toast.makeText(mContext, R.string.adb_wireless_no_network_msg,
Toast.LENGTH_LONG);
}
@Override
public void onStartListening() {
super.onStartListening();
getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.ADB_WIFI_ENABLED), false,
mSettingsObserver);
}
@Override
public void onStopListening() {
super.onStopListening();
getContentResolver().unregisterContentObserver(mSettingsObserver);
}
@Override
protected boolean isEnabled() {
return isAdbWifiEnabled();
}
@Override
public void setIsEnabled(boolean isEnabled) {
// Don't allow Wireless Debugging to be enabled from the lock screen.
if (isEnabled && mKeyguardManager.isKeyguardLocked()) {
return;
}
// Show error toast if not connected to Wi-Fi
if (isEnabled && !WirelessDebuggingPreferenceController.isWifiConnected(mContext)) {
// Close quick shade
sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
mToast.show();
return;
}
writeAdbWifiSetting(isEnabled);
}
private boolean isAdbWifiEnabled() {
return Settings.Global.getInt(getContentResolver(), Settings.Global.ADB_WIFI_ENABLED,
ADB_SETTING_OFF) != ADB_SETTING_OFF;
}
protected void writeAdbWifiSetting(boolean enabled) {
Settings.Global.putInt(getContentResolver(), Settings.Global.ADB_WIFI_ENABLED,
enabled ? ADB_SETTING_ON : ADB_SETTING_OFF);
}
}
}

View File

@@ -20,6 +20,7 @@ import android.accounts.Account;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -63,23 +64,29 @@ public class BrandedAccountPreferenceController extends BasePreferenceController
}
accountPreference.setSummary(mAccounts[0].name);
accountPreference.setOnPreferenceClickListener(preference -> {
final Bundle args = new Bundle();
args.putParcelable(AccountDetailDashboardFragment.KEY_ACCOUNT,
mAccounts[0]);
args.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE,
android.os.Process.myUserHandle());
args.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_TYPE,
mAccountFeatureProvider.getAccountType());
}
new SubSettingLauncher(mContext)
.setDestination(AccountDetailDashboardFragment.class.getName())
.setTitleRes(R.string.account_sync_title)
.setArguments(args)
.setSourceMetricsCategory(SettingsEnums.DEVICEINFO)
.launch();
return true;
});
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
return false;
}
final Bundle args = new Bundle();
args.putParcelable(AccountDetailDashboardFragment.KEY_ACCOUNT,
mAccounts[0]);
args.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE,
android.os.Process.myUserHandle());
args.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_TYPE,
mAccountFeatureProvider.getAccountType());
new SubSettingLauncher(mContext)
.setDestination(AccountDetailDashboardFragment.class.getName())
.setTitleRes(R.string.account_sync_title)
.setArguments(args)
.setSourceMetricsCategory(SettingsEnums.DEVICEINFO)
.launch();
return true;
}
@Override

View File

@@ -23,7 +23,6 @@ import android.content.Intent;
import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.view.View;
import com.android.settings.R;
@@ -50,7 +49,6 @@ import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.widget.LayoutPreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@SearchIndexable

View File

@@ -415,14 +415,16 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
if (signalStrength == null) {
return;
}
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
final PersistableBundle carrierConfig =
mCarrierConfigManager.getConfigForSubId(subscriptionId);
// by default we show the signal strength
boolean showSignalStrength = true;
if (carrierConfig != null) {
showSignalStrength = carrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL);
if (mSubscriptionInfo != null) {
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
final PersistableBundle carrierConfig =
mCarrierConfigManager.getConfigForSubId(subscriptionId);
if (carrierConfig != null) {
showSignalStrength = carrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL);
}
}
if (!showSignalStrength) {
mDialog.removeSettingFromScreen(SIGNAL_STRENGTH_LABEL_ID);
@@ -455,6 +457,14 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
}
private void updateNetworkType() {
if (mSubscriptionInfo == null) {
final String unknownNetworkType =
getNetworkTypeName(TelephonyManager.NETWORK_TYPE_UNKNOWN);
mDialog.setText(CELL_VOICE_NETWORK_TYPE_VALUE_ID, unknownNetworkType);
mDialog.setText(CELL_DATA_NETWORK_TYPE_VALUE_ID, unknownNetworkType);
return;
}
// Whether EDGE, UMTS, etc...
String dataNetworkTypeName = null;
String voiceNetworkTypeName = null;
@@ -497,14 +507,16 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
}
private void updateIccidNumber() {
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
final PersistableBundle carrierConfig =
mCarrierConfigManager.getConfigForSubId(subscriptionId);
// do not show iccid by default
boolean showIccId = false;
if (carrierConfig != null) {
showIccId = carrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL);
if (mSubscriptionInfo != null) {
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
final PersistableBundle carrierConfig =
mCarrierConfigManager.getConfigForSubId(subscriptionId);
if (carrierConfig != null) {
showIccId = carrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL);
}
}
if (!showIccId) {
mDialog.removeSettingFromScreen(ICCID_INFO_LABEL_ID);
@@ -556,6 +568,9 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
}
private boolean isImsRegistrationStateShowUp() {
if (mSubscriptionInfo == null) {
return false;
}
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
final PersistableBundle carrierConfig =
mCarrierConfigManager.getConfigForSubId(subscriptionId);

View File

@@ -16,7 +16,6 @@
package com.android.settings.dream;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.widget.Button;
@@ -25,6 +24,7 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -62,7 +62,8 @@ public class StartNowPreferenceController extends AbstractPreferenceController i
LayoutPreference pref = screen.findPreference(getPreferenceKey());
Button startButton = pref.findViewById(R.id.dream_start_now_button);
startButton.setOnClickListener(v -> {
mMetricsFeatureProvider.logClickedPreference(pref, SettingsEnums.DREAM);
mMetricsFeatureProvider.logClickedPreference(pref,
pref.getExtras().getInt(DashboardFragment.CATEGORY));
mBackend.startDreaming();
});
}

View File

@@ -17,11 +17,14 @@
package com.android.settings.location;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import androidx.preference.Preference;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.RestrictedAppPreference;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.location.InjectedSetting;
import com.android.settingslib.location.SettingsInjector;
import com.android.settingslib.widget.apppreference.AppPreference;
@@ -31,8 +34,13 @@ import com.android.settingslib.widget.apppreference.AppPreference;
*/
public class AppSettingsInjector extends SettingsInjector {
public AppSettingsInjector(Context context) {
private final MetricsFeatureProvider mMetricsFeatureProvider;
private final int mMetricsCategory;
public AppSettingsInjector(Context context, int metricsCategory) {
super(context);
mMetricsCategory = metricsCategory;
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Override
@@ -41,4 +49,9 @@ public class AppSettingsInjector extends SettingsInjector {
? new AppPreference(prefContext)
: new RestrictedAppPreference(prefContext, setting.userRestriction);
}
@Override
protected void logPreferenceClick(Intent intent) {
mMetricsFeatureProvider.logStartedIntent(intent, mMetricsCategory);
}
}

View File

@@ -58,7 +58,7 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
@Override
public void init(DashboardFragment fragment) {
super.init(fragment);
mInjector = new AppSettingsInjector(mContext);
mInjector = new AppSettingsInjector(mContext, getMetricsCategory());
}
@Override

View File

@@ -2,6 +2,7 @@
allenwtsu@google.com
andychou@google.com
bonianchen@google.com
leechou@google.com
songferngwang@google.com
tomhsu@google.com

View File

@@ -48,6 +48,8 @@ import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.DeviceInfoUtils;
import java.util.List;
/**
* A dialog allowing the display name of a mobile network subscription to be changed
*/
@@ -115,9 +117,9 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
.setPositiveButton(R.string.mobile_network_sim_name_rename, (dialog, which) -> {
mSubscriptionManager.setDisplayName(mNameView.getText().toString(), mSubId,
SubscriptionManager.NAME_SOURCE_USER_INPUT);
mSubscriptionManager.setIconTint(
mColors[mColorSpinner.getSelectedItemPosition()].getColor(),
mSubId);
final Color color = (mColorSpinner == null) ? mColors[0]
: mColors[mColorSpinner.getSelectedItemPosition()];
mSubscriptionManager.setIconTint(color.getColor(), mSubId);
})
.setNegativeButton(android.R.string.cancel, null);
return builder.create();
@@ -126,7 +128,17 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
@VisibleForTesting
protected void populateView(View view) {
mNameView = view.findViewById(R.id.name_edittext);
final SubscriptionInfo info = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
SubscriptionInfo info = null;
final List<SubscriptionInfo> infoList = mSubscriptionManager
.getAvailableSubscriptionInfoList();
if (infoList != null) {
for (SubscriptionInfo subInfo : infoList) {
if (subInfo.getSubscriptionId() == mSubId) {
info = subInfo;
break;
}
}
}
if (info == null) {
Log.w(TAG, "got null SubscriptionInfo for mSubId:" + mSubId);
return;

View File

@@ -311,8 +311,9 @@ public class ChooseLockGeneric extends SettingsActivity {
@Override
public boolean onPreferenceTreeClick(Preference preference) {
final String key = preference.getKey();
writePreferenceClickMetric(preference);
final String key = preference.getKey();
if (!isUnlockMethodSecure(key) && mLockPatternUtils.isSecure(mUserId)) {
// Show the disabling FRP warning only when the user is switching from a secure
// unlock method to an insecure one

View File

@@ -31,6 +31,7 @@ import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.security.screenlock.ScreenLockSettings;
@@ -39,6 +40,7 @@ import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
public class ChangeScreenLockPreferenceController extends AbstractPreferenceController implements
PreferenceControllerMixin, GearPreference.OnGearClickListener {
@@ -52,6 +54,7 @@ public class ChangeScreenLockPreferenceController extends AbstractPreferenceCont
protected final int mUserId = UserHandle.myUserId();
protected final int mProfileChallengeUserId;
private final MetricsFeatureProvider mMetricsFeatureProvider;
protected RestrictedPreference mPreference;
@@ -64,6 +67,7 @@ public class ChangeScreenLockPreferenceController extends AbstractPreferenceCont
.getLockPatternUtils(context);
mHost = host;
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, mUserId);
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Override
@@ -104,6 +108,8 @@ public class ChangeScreenLockPreferenceController extends AbstractPreferenceCont
@Override
public void onGearClick(GearPreference p) {
if (TextUtils.equals(p.getKey(), getPreferenceKey())) {
mMetricsFeatureProvider.logClickedPreference(p,
p.getExtras().getInt(DashboardFragment.CATEGORY));
new SubSettingLauncher(mContext)
.setDestination(ScreenLockSettings.class.getName())
.setSourceMetricsCategory(mHost.getMetricsCategory())

View File

@@ -1596,15 +1596,8 @@ public class WifiConfigController implements TextWatcher,
} else if (parent == mProxySettingsSpinner) {
showProxyFields();
} else if (parent == mHiddenSettingsSpinner) {
mHiddenWarningView.setVisibility(
position == NOT_HIDDEN_NETWORK
? View.GONE
: View.VISIBLE);
if (position == HIDDEN_NETWORK) {
mDialogContainer.post(() -> {
mDialogContainer.fullScroll(View.FOCUS_DOWN);
});
}
mHiddenWarningView.setVisibility(position == NOT_HIDDEN_NETWORK
? View.GONE : View.VISIBLE);
} else {
showIpConfigFields();
}

View File

@@ -1592,15 +1592,8 @@ public class WifiConfigController2 implements TextWatcher,
} else if (parent == mProxySettingsSpinner) {
showProxyFields();
} else if (parent == mHiddenSettingsSpinner) {
mHiddenWarningView.setVisibility(
position == NOT_HIDDEN_NETWORK
? View.GONE
: View.VISIBLE);
if (position == HIDDEN_NETWORK) {
mDialogContainer.post(() -> {
mDialogContainer.fullScroll(View.FOCUS_DOWN);
});
}
mHiddenWarningView.setVisibility(position == NOT_HIDDEN_NETWORK
? View.GONE : View.VISIBLE);
} else {
showIpConfigFields();
}

View File

@@ -2,6 +2,7 @@
allenwtsu@google.com
andychou@google.com
bonianchen@google.com
leechou@google.com
songferngwang@google.com
tomhsu@google.com

View File

@@ -0,0 +1,220 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development.qstile;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings.Global;
import android.widget.Toast;
import com.android.settings.testutils.shadow.ShadowWirelessDebuggingPreferenceController;
import org.junit.After;
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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowWirelessDebuggingPreferenceController.class})
public class WirelessDebuggingTest {
@Mock
private Toast mToast;
@Mock
private KeyguardManager mKeyguardManager;
private Context mContext;
private DevelopmentTiles.WirelessDebugging mWirelessDebugging;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mWirelessDebugging = spy(new DevelopmentTiles.WirelessDebugging());
doReturn(mContext.getContentResolver()).when(mWirelessDebugging).getContentResolver();
ReflectionHelpers.setField(mWirelessDebugging, "mKeyguardManager", mKeyguardManager);
ReflectionHelpers.setField(mWirelessDebugging, "mToast", mToast);
}
@After
public void tearDown() {
ShadowWirelessDebuggingPreferenceController.reset();
}
@Test
public void adbWifiEnabled_shouldReturnEnabled() {
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 1 /* setting enabled */);
assertThat(mWirelessDebugging.isEnabled()).isTrue();
}
@Test
public void adbWifiDisabled_shouldReturnDisabled() {
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 0 /* setting disabled */);
assertThat(mWirelessDebugging.isEnabled()).isFalse();
}
@Test
public void setIsEnabled_false_keyguardUnlocked_WifiDisconnected_shouldDisableAdbWifi() {
// Precondition: set the tile to enabled
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 1 /* setting enabled */);
// Unlocked keyguard
doReturn(false).when(mKeyguardManager).isKeyguardLocked();
// Wifi disconnected
ShadowWirelessDebuggingPreferenceController.setIsWifiConnected(false);
mWirelessDebugging.setIsEnabled(false);
assertThat(mWirelessDebugging.isEnabled()).isFalse();
}
@Test
public void setIsEnabled_false_keyguardLocked_WifiDisconnected_shouldDisableAdbWifi() {
// Precondition: set the tile to enabled
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 1 /* setting enabled */);
// Locked keyguard
doReturn(true).when(mKeyguardManager).isKeyguardLocked();
// Wifi disconnected
ShadowWirelessDebuggingPreferenceController.setIsWifiConnected(false);
mWirelessDebugging.setIsEnabled(false);
assertThat(mWirelessDebugging.isEnabled()).isFalse();
}
@Test
public void setIsEnabled_false_keyguardUnlocked_WifiConnected_shouldDisableAdbWifi() {
// Precondition: set the tile to enabled
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 1 /* setting enabled */);
// Unlocked keyguard
doReturn(false).when(mKeyguardManager).isKeyguardLocked();
// Wifi connected
ShadowWirelessDebuggingPreferenceController.setIsWifiConnected(true);
mWirelessDebugging.setIsEnabled(false);
assertThat(mWirelessDebugging.isEnabled()).isFalse();
}
@Test
public void setIsEnabled_false_keyguardLocked_WifiConnected_shouldDisableAdbWifi() {
// Precondition: set the tile to enabled
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 1 /* setting enabled */);
// Locked keyguard
doReturn(true).when(mKeyguardManager).isKeyguardLocked();
// Wifi connected
ShadowWirelessDebuggingPreferenceController.setIsWifiConnected(true);
mWirelessDebugging.setIsEnabled(false);
assertThat(mWirelessDebugging.isEnabled()).isFalse();
}
@Test
public void setIsEnabled_true_keyguardUnlocked_WifiDisconnected_shouldDisableAdbWifi() {
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
doNothing().when(mWirelessDebugging).sendBroadcast(intentCaptor.capture());
// Precondition: set the tile to disabled
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 0 /* setting enabled */);
// Unlocked keyguard
doReturn(false).when(mKeyguardManager).isKeyguardLocked();
// Wifi disconnected
ShadowWirelessDebuggingPreferenceController.setIsWifiConnected(false);
mWirelessDebugging.setIsEnabled(true);
assertThat(mWirelessDebugging.isEnabled()).isFalse();
// The notification shade should be hidden by sending a broadcast to SysUI
// so the toast can be seen
verify(mWirelessDebugging, times(1)).sendBroadcast(eq(intentCaptor.getValue()));
assertThat(intentCaptor.getValue().getAction())
.isEqualTo(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
// Should also get a toast that wifi is not connected
verify(mToast).show();
}
@Test
public void setIsEnabled_true_keyguardLocked_WifiDisconnected_shouldDisableAdbWifi() {
// Precondition: set the tile to disabled
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 0 /* setting enabled */);
// Locked keyguard
doReturn(true).when(mKeyguardManager).isKeyguardLocked();
// Wifi disconnected
ShadowWirelessDebuggingPreferenceController.setIsWifiConnected(false);
mWirelessDebugging.setIsEnabled(true);
// Shouldn't be able to enable wireless debugging from locked screen
assertThat(mWirelessDebugging.isEnabled()).isFalse();
}
@Test
public void setIsEnabled_true_keyguardUnlocked_WifiConnected_shouldDisableAdbWifi() {
// Precondition: set the tile to disabled
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 0 /* setting enabled */);
// Unlocked keyguard
doReturn(false).when(mKeyguardManager).isKeyguardLocked();
// Wifi connected
ShadowWirelessDebuggingPreferenceController.setIsWifiConnected(true);
mWirelessDebugging.setIsEnabled(true);
assertThat(mWirelessDebugging.isEnabled()).isTrue();
}
@Test
public void setIsEnabled_true_keyguardLocked_WifiConnected_shouldDisableAdbWifi() {
// Precondition: set the tile to disabled
Global.putInt(mContext.getContentResolver(),
Global.ADB_WIFI_ENABLED, 0 /* setting enabled */);
// Locked keyguard
doReturn(true).when(mKeyguardManager).isKeyguardLocked();
// Wifi connected
ShadowWirelessDebuggingPreferenceController.setIsWifiConnected(true);
mWirelessDebugging.setIsEnabled(true);
// Shouldn't be able to enable wireless debugging from locked screen
assertThat(mWirelessDebugging.isEnabled()).isFalse();
}
}

View File

@@ -23,12 +23,12 @@ 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.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.telephony.ServiceState;
@@ -56,7 +56,13 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowTelephonyManager;
import java.util.ArrayList;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowAlertDialogCompat.class)
@@ -65,6 +71,8 @@ public class RenameMobileNetworkDialogFragmentTest {
@Mock
private TelephonyManager mTelephonyMgr;
@Mock
private ServiceState mServiceState;
@Mock
private SubscriptionManager mSubscriptionMgr;
@Mock
private SubscriptionInfo mSubscriptionInfo;
@@ -72,23 +80,35 @@ public class RenameMobileNetworkDialogFragmentTest {
private FragmentActivity mActivity;
private RenameMobileNetworkDialogFragment mFragment;
private int mSubscriptionId = 1234;
private List<SubscriptionInfo> mSubscriptionInfoList;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
Context context = spy(RuntimeEnvironment.application);
final ShadowTelephonyManager stm = Shadow.extract(context.getSystemService(
TelephonyManager.class));
stm.setTelephonyManagerForSubscriptionId(mSubscriptionId, mTelephonyMgr);
when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
when(mTelephonyMgr.getServiceState()).thenReturn(mServiceState);
when(mServiceState.getOperatorAlphaLong()).thenReturn("fake carrier name");
when(mSubscriptionInfo.getSubscriptionId()).thenReturn(mSubscriptionId);
when(mSubscriptionInfo.getDisplayName()).thenReturn("test");
when(mSubscriptionMgr.setDisplayName(any(), anyInt(), anyInt())).thenReturn(0);
mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
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.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
when(mTelephonyMgr.getServiceState()).thenReturn(serviceState);
mSubscriptionInfoList = new ArrayList<SubscriptionInfo>();
mSubscriptionInfoList.add(mSubscriptionInfo);
when(mSubscriptionMgr.getAvailableSubscriptionInfoList()).thenReturn(
mSubscriptionInfoList);
}
@Test
@@ -101,10 +121,7 @@ public class RenameMobileNetworkDialogFragmentTest {
}
@Test
@Ignore
public void dialog_cancelButtonClicked_setDisplayNameAndIconTintNotCalled() {
when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
mSubscriptionInfo);
final AlertDialog dialog = startDialog();
final EditText nameView = mFragment.getNameView();
nameView.setText("test2");
@@ -117,11 +134,7 @@ public class RenameMobileNetworkDialogFragmentTest {
}
@Test
@Ignore
public void dialog_saveButtonClicked_setDisplayNameAndIconTint() {
when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
mSubscriptionInfo);
final AlertDialog dialog = startDialog();
final EditText nameView = mFragment.getNameView();
nameView.setText("test2");
@@ -141,12 +154,9 @@ public class RenameMobileNetworkDialogFragmentTest {
}
@Test
@Ignore
public void populateView_infoIsOpportunistic_hideNumberLabel() {
final View view = LayoutInflater.from(mActivity).inflate(
R.layout.dialog_mobile_network_rename, null);
when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
mSubscriptionInfo);
when(mSubscriptionInfo.isOpportunistic()).thenReturn(true);
startDialog();