Snap for 4906041 from c01cb892b1 to qt-release

Change-Id: I1bc6faede1d9951ae1bf8f6fdf1ebdb66e61c34a
This commit is contained in:
android-build-team Robot
2018-07-22 03:06:06 +00:00
197 changed files with 1337 additions and 1457 deletions

View File

@@ -28,8 +28,9 @@
android:minHeight="@dimen/min_tap_target_size"
android:gravity="top"
android:hint="@string/owner_info_settings_edit_text_hint"
android:inputType="textMultiLine|textCapSentences"
/>
android:inputType="textMultiLine|textCapSentences">
<requestFocus />
</EditText>
</LinearLayout>

View File

@@ -2112,8 +2112,6 @@
<string name="wifi_forget_dialog_message">All passwords for this network will be deleted</string>
<!-- Wi-Fi Advanced Settings --> <skip />
<!-- Wi-Fi settings screen, Saved networks, settings section. This is a header shown above Saved networks wifi settings. [CHAR LIMIT=30] -->
<string name="wifi_saved_access_points_titlebar">Saved networks</string>
<!-- Wi-Fi settings screen, Saved networks summary. This shows below the "Saved networks" item and indicates the number of networks a user has saved. -->
<plurals name="wifi_saved_access_points_summary">
<item quantity="one">1 network</item>
@@ -5945,8 +5943,8 @@
<!-- Activity title for network data usage summary. [CHAR LIMIT=25] -->
<string name="data_usage_summary_title">Data usage</string>
<!-- Activity title for Appk data usage summary. [CHAR LIMIT=25] -->
<string name="data_usage_app_summary_title">App data usage</string>
<!-- Activity title Mobile data & WI-FI summary. [CHAR LIMIT=25] -->
<string name="data_usage_app_summary_title">Mobile data &amp; Wi\u2011Fi</string>
<!-- Message about carrier data accounting. [CHAR LIMIT=100] -->
<string name="data_usage_accounting">Carrier data accounting may differ from your device.</string>
<!-- Title for app usage. [CHAR LIMIT=40] -->

View File

@@ -17,7 +17,7 @@
<resources>
<style name="Transparent">
<item name="android:alertDialogTheme">@style/Theme.AlertDialog</item>
<item name="alertDialogTheme">@style/Theme.AlertDialog</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
@@ -45,8 +45,8 @@
<item name="preferenceBackgroundColor">@drawable/preference_background</item>
<!-- For all androidx version of AlertDialogs -->
<item name="alertDialogTheme">@style/Theme.AppCompat.DayNight.Dialog.Alert</item>
<!-- For AndroidX AlertDialog -->
<item name="alertDialogTheme">@style/Theme.AlertDialog</item>
<item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
@@ -106,11 +106,15 @@
<item name="android:windowSoftInputMode">adjustResize</item>
</style>
<style name="Theme.AlertDialog" parent="@*android:style/Theme.DeviceDefault.Settings.Dialog.Alert">
<style name="Theme.AlertDialog" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
<item name="android:windowSoftInputMode">adjustResize</item>
<!-- Redefine the ActionBar style for contentInsetStart -->
<item name="android:actionBarStyle">@style/Theme.ActionBar</item>
<!-- copied from Theme.DeviceDefault.Light.Dialog.Alert -->
<item name="colorAccent">@*android:color/accent_device_default_light</item>
<item name="dialogCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
</style>
<style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings">
@@ -166,6 +170,7 @@
<item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
<item name="colorPrimaryDark">@*android:color/primary_dark_device_default_settings_light</item>
<item name="android:colorAccent">@*android:color/accent_device_default_light</item>
<item name="android:windowLightStatusBar">true</item>
</style>
</resources>

View File

@@ -63,7 +63,7 @@
<Preference
android:key="data_settings"
android:title="@string/data_usage_summary_title"
android:title="@string/data_usage_app_summary_title"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.applications.appinfo.AppDataUsagePreferenceController" />

View File

@@ -23,8 +23,10 @@
<com.android.settings.widget.VideoPreference
android:key="auto_brightness_video"
android:title="@string/summary_placeholder"
settings:animation="@raw/aab_brightness"
settings:preview="@drawable/aab_brightness"/>
settings:preview="@drawable/aab_brightness"
settings:controller="com.android.settings.widget.VideoPreferenceController"/>
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
<com.android.settingslib.RestrictedSwitchPreference

View File

@@ -23,8 +23,10 @@
<com.android.settings.widget.VideoPreference
android:key="auto_awesome_battery"
android:title="@string/summary_placeholder"
settings:animation="@raw/auto_awesome_battery"
settings:preview="@drawable/auto_awesome_battery"/>
settings:preview="@drawable/auto_awesome_battery"
settings:controller="com.android.settings.widget.VideoPreferenceController"/>
<SwitchPreference
android:key="smart_battery"

View File

@@ -14,7 +14,15 @@
limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/wifi_saved_access_points_titlebar">
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="saved_access_points"
android:title="@string/wifi_saved_access_points_label">
<PreferenceCategory
android:key="saved_access_points_category"
android:layout="@layout/preference_category_no_label"
settings:controller="com.android.settings.wifi.savedaccesspoints.SavedAccessPointsPreferenceController"/>
</PreferenceScreen>

View File

@@ -16,7 +16,6 @@
package com.android.settings;
import android.app.AlertDialog;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
@@ -33,6 +32,8 @@ import android.widget.CheckBox;
import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
import androidx.appcompat.app.AlertDialog;
/**
* This activity is displayed when an app launches the BIND_APPWIDGET intent. This allows apps
* that don't have the BIND_APPWIDGET permission to bind specific widgets.

View File

@@ -1,7 +1,6 @@
package com.android.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.AsyncResult;
import android.os.Bundle;
@@ -18,6 +17,7 @@ import android.widget.ListView;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import androidx.appcompat.app.AlertDialog;
/**
* Radio Band Mode Selection Class

View File

@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.DialogInterface;
@@ -49,6 +48,7 @@ import com.android.settings.vpn2.VpnUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
import sun.security.util.ObjectIdentifier;
import sun.security.x509.AlgorithmId;

View File

@@ -18,7 +18,6 @@ package com.android.settings;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -42,6 +41,8 @@ import com.android.setupwizardlib.GlifLayout;
import java.util.List;
import androidx.appcompat.app.AlertDialog;
public class EncryptionInterstitial extends SettingsActivity {
private static final String TAG = EncryptionInterstitial.class.getSimpleName();

View File

@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@@ -29,6 +28,8 @@ import android.provider.Settings;
import com.android.settingslib.RestrictedLockUtils;
import androidx.appcompat.app.AlertDialog;
/**
* Activity that shows a dialog explaining that a CA cert is allowing someone to monitor network
* traffic. This activity should be launched for the user into which the CA cert is installed

View File

@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -43,6 +42,8 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.SettingsPreferenceFragment.SettingsDialogFragment;
import com.android.settings.core.InstrumentedFragment;
import androidx.appcompat.app.AlertDialog;
public class ProxySelector extends InstrumentedFragment implements DialogCreatable {
private static final String TAG = "ProxySelector";

View File

@@ -20,7 +20,6 @@ import static android.net.ConnectivityManager.NetworkCallback;
import static android.provider.Settings.Global.PREFERRED_NETWORK_MODE;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.QueuedWork;
import android.content.ComponentName;
import android.content.Context;
@@ -91,6 +90,8 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import androidx.appcompat.app.AlertDialog;
public class RadioInfo extends Activity {
private static final String TAG = "RadioInfo";

View File

@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -34,6 +33,7 @@ import android.widget.TextView;
import java.util.Locale;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
/**
* {@link Activity} that displays regulatory information for the "Regulatory information"

View File

@@ -17,7 +17,6 @@ package com.android.settings;
import android.annotation.Nullable;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.DialogInterface;
import android.content.Intent;
@@ -25,6 +24,8 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;
/**
* UI for the remote bugreport dialog. Shows one of 3 possible dialogs:
* <ul>

View File

@@ -18,7 +18,6 @@ package com.android.settings;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.ContentResolver;
@@ -50,6 +49,7 @@ import com.android.settings.network.ApnSettings;
import com.android.settingslib.RestrictedLockUtils;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
/**
* Confirm and execute a reset of the network settings to a clean "just out of the box"

View File

@@ -18,7 +18,6 @@ package com.android.settings;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.AlertDialog;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.DialogInterface;
@@ -41,6 +40,7 @@ import com.android.settingslib.RestrictedPreferenceHelper;
import java.util.ArrayList;
import java.util.List;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AlertDialog.Builder;
import androidx.preference.ListPreferenceDialogFragmentCompat;
import androidx.preference.PreferenceViewHolder;

View File

@@ -19,7 +19,6 @@ package com.android.settings;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -37,6 +36,7 @@ import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
import com.android.settingslib.RestrictedLockUtils;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
/**
* Base class for settings screens that should be pin protected when in restricted mode or

View File

@@ -17,7 +17,6 @@ package com.android.settings;
import android.annotation.NonNull;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.DialogInterface;
import android.content.pm.UserInfo;
@@ -41,6 +40,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.IntConsumer;
import androidx.appcompat.app.AlertDialog;
class TrustedCredentialsDialogBuilder extends AlertDialog.Builder {
public interface DelegateInterface {
List<X509Certificate> getX509CertsFromCertHolder(CertHolder certHolder);

View File

@@ -18,7 +18,6 @@ package com.android.settings;
import android.annotation.LayoutRes;
import android.annotation.Nullable;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -57,6 +56,7 @@ import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

View File

@@ -389,9 +389,7 @@ public final class Utils extends com.android.settingslib.Utils {
*/
public static UserHandle getManagedProfile(UserManager userManager) {
List<UserHandle> userProfiles = userManager.getUserProfiles();
final int count = userProfiles.size();
for (int i = 0; i < count; i++) {
final UserHandle profile = userProfiles.get(i);
for (UserHandle profile : userProfiles) {
if (profile.getIdentifier() == userManager.getUserHandle()) {
continue;
}

View File

@@ -20,7 +20,6 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYST
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -41,6 +40,8 @@ import com.android.settings.R;
import java.util.List;
import java.util.Locale;
import androidx.appcompat.app.AlertDialog;
/**
* Utility class for creating the dialog that asks users for explicit permission to grant
* all of the requested capabilities to an accessibility service before the service is enabled

View File

@@ -18,7 +18,6 @@ package com.android.settings.accessibility;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@@ -46,6 +45,8 @@ import com.android.settingslib.accessibility.AccessibilityUtils;
import java.util.List;
import androidx.appcompat.app.AlertDialog;
public class ToggleAccessibilityServicePreferenceFragment
extends ToggleFeaturePreferenceFragment implements DialogInterface.OnClickListener {

View File

@@ -19,7 +19,6 @@ package com.android.settings.accounts;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentResolver;
import android.content.Context;
@@ -53,6 +52,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
public class AccountSyncSettings extends AccountPreferenceBase {

View File

@@ -22,7 +22,6 @@ import android.accounts.AccountManagerFuture;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -45,6 +44,7 @@ import com.android.settingslib.core.AbstractPreferenceController;
import java.io.IOException;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceScreen;

View File

@@ -19,7 +19,6 @@ package com.android.settings.applications;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
@@ -51,6 +50,7 @@ import com.android.settingslib.applications.ApplicationsState.AppEntry;
import java.util.ArrayList;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;

View File

@@ -21,7 +21,6 @@ import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATIO
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
@@ -42,6 +41,7 @@ import com.android.settings.Utils;
import java.util.List;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.DropDownPreference;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;

View File

@@ -22,7 +22,6 @@ import static android.os.storage.StorageVolume.ScopedAccessProviderContract.AUTH
import static android.os.storage.StorageVolume.ScopedAccessProviderContract.TABLE_PERMISSIONS;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.AppGlobals;
import android.app.GrantedUriPermission;
import android.content.ContentResolver;
@@ -64,6 +63,7 @@ import java.util.Objects;
import java.util.TreeMap;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
import androidx.preference.Preference;

View File

@@ -34,7 +34,6 @@ import static com.android.settings.applications.AppStateDirectoryAccessBridge.VE
import android.annotation.Nullable;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
@@ -60,6 +59,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;

View File

@@ -21,7 +21,6 @@ import static com.android.settings.widget.EntityHeaderController.ActionType;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
@@ -59,6 +58,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;

View File

@@ -2,7 +2,6 @@ package com.android.settings.applications;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.ApplicationErrorReport;
import android.app.Dialog;
import android.app.PendingIntent;
@@ -44,6 +43,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
public class RunningServiceDetails extends InstrumentedFragment

View File

@@ -15,7 +15,6 @@
*/
package com.android.settings.applications;
import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@@ -32,6 +31,7 @@ import com.android.settings.applications.AppStateUsageBridge.UsageState;
import com.android.settings.overlay.FeatureFactory;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.Preference.OnPreferenceClickListener;

View File

@@ -15,7 +15,6 @@
*/
package com.android.settings.applications.appinfo;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -30,6 +29,7 @@ import java.lang.annotation.RetentionPolicy;
import androidx.annotation.IntDef;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
/**
* Fragment to show the dialog for uninstall or forcestop. This fragment uses function in

View File

@@ -17,7 +17,6 @@ package com.android.settings.applications.appinfo;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
@@ -38,6 +37,7 @@ import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.Preference.OnPreferenceClickListener;

View File

@@ -18,7 +18,6 @@ package com.android.settings.applications.appinfo;
import static android.app.Activity.RESULT_CANCELED;
import static android.app.Activity.RESULT_OK;
import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.content.Context;
import android.os.Bundle;
@@ -34,6 +33,7 @@ import com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsSt
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;

View File

@@ -15,7 +15,6 @@
*/
package com.android.settings.applications.appinfo;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -28,6 +27,8 @@ import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.overlay.FeatureFactory;
import androidx.appcompat.app.AlertDialog;
/**
* Fragment to show the dialog for clearing the instant app.
*/

View File

@@ -15,7 +15,6 @@
*/
package com.android.settings.applications.appinfo;
import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
@@ -33,6 +32,7 @@ import com.android.settings.applications.AppStateWriteSettingsBridge.WriteSettin
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.Preference.OnPreferenceClickListener;

View File

@@ -16,7 +16,6 @@
package com.android.settings.applications.defaultapps;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -34,6 +33,7 @@ import com.android.settings.widget.RadioButtonPreference;
import com.android.settingslib.applications.DefaultAppInfo;
import com.android.settingslib.widget.CandidateInfo;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

View File

@@ -54,6 +54,7 @@ import android.os.UserManager;
import android.preference.PreferenceFrameLayout;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.IconDrawableFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -862,6 +863,7 @@ public class ManageApplications extends InstrumentedFragment
private final Context mContext;
private final AppStateBaseBridge mExtraInfoBridge;
private final LoadingViewController mLoadingViewController;
private final IconDrawableFactory mIconDrawableFactory;
private AppFilterItem mAppFilter;
private ArrayList<ApplicationsState.AppEntry> mEntries;
@@ -894,6 +896,7 @@ public class ManageApplications extends InstrumentedFragment
mManageApplications.mListContainer
);
mContext = manageApplications.getActivity();
mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
mAppFilter = appFilter;
if (mManageApplications.mListType == LIST_TYPE_NOTIFICATION) {
mExtraInfoBridge = new AppStateNotificationBridge(mContext, mState, this,
@@ -1318,8 +1321,7 @@ public class ManageApplications extends InstrumentedFragment
ApplicationsState.AppEntry entry = mEntries.get(position);
synchronized (entry) {
holder.setTitle(entry.label);
mState.ensureIcon(entry);
holder.setIcon(entry.icon);
holder.setIcon(mIconDrawableFactory.getBadgedIcon(entry.info));
updateSummary(holder, entry);
updateSwitch(holder, entry);
holder.updateDisableView(entry.info);

View File

@@ -19,7 +19,6 @@ import static android.net.NetworkPolicyManager.POLICY_NONE;
import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.INotificationManager;
import android.content.Context;
@@ -39,6 +38,8 @@ import com.android.settings.R;
import java.util.List;
import androidx.appcompat.app.AlertDialog;
public class ResetAppsHelper implements DialogInterface.OnClickListener,
DialogInterface.OnDismissListener {

View File

@@ -18,7 +18,6 @@ package com.android.settings.applications.specialaccess.deviceadmin;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.Dialog;
import android.app.admin.DeviceAdminInfo;
@@ -74,6 +73,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import androidx.appcompat.app.AlertDialog;
public class DeviceAdminAdd extends Activity {
static final String TAG = "DeviceAdminAdd";

View File

@@ -19,7 +19,6 @@ import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.MODE_ERRORED;
import static android.app.AppOpsManager.OP_PICTURE_IN_PICTURE;
import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.content.Context;
import android.os.Bundle;
@@ -30,6 +29,7 @@ import com.android.settings.applications.AppInfoWithHeader;
import com.android.settings.overlay.FeatureFactory;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.SwitchPreference;

View File

@@ -1,6 +1,5 @@
package com.android.settings.backup;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.backup.IBackupManager;
import android.content.Context;
@@ -20,6 +19,7 @@ import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.ToggleSwitch;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.PreferenceViewHolder;

View File

@@ -20,7 +20,6 @@ import static com.android.settings.biometrics.BiometricSettings.RESULT_FINISHED;
import static com.android.settings.biometrics.BiometricSettings.RESULT_TIMEOUT;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.hardware.biometrics.BiometricConstants;
@@ -28,6 +27,8 @@ import android.os.Bundle;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
/**
* Abstract dialog, shown when an error occurs during biometric enrollment.
*/

View File

@@ -109,7 +109,8 @@ public abstract class BiometricsEnrollEnrolling extends BiometricEnrollBase
.findFragmentByTag(TAG_SIDECAR);
if (mSidecar == null) {
mSidecar = getSidecar();
getSupportFragmentManager().beginTransaction().add(mSidecar, TAG_SIDECAR).commit();
getSupportFragmentManager().beginTransaction().add(mSidecar, TAG_SIDECAR)
.commitAllowingStateLoss();
}
mSidecar.setListener(this);
}

View File

@@ -18,7 +18,6 @@ package com.android.settings.biometrics.fingerprint;
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -47,6 +46,8 @@ import com.android.settings.biometrics.BiometricErrorDialog;
import com.android.settings.biometrics.BiometricsEnrollEnrolling;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
/**
* Activity which handles the actual enrolling for fingerprint.
*/

View File

@@ -18,7 +18,6 @@ package com.android.settings.biometrics.fingerprint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -57,6 +56,7 @@ import java.util.HashMap;
import java.util.List;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceGroup;

View File

@@ -17,7 +17,6 @@
package com.android.settings.biometrics.fingerprint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -32,6 +31,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.password.ChooseLockSettingsHelper;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor {

View File

@@ -18,7 +18,6 @@ package com.android.settings.bluetooth;
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
import android.app.AlertDialog;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.DialogInterface;
@@ -39,6 +38,7 @@ import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;

View File

@@ -16,7 +16,6 @@
package com.android.settings.bluetooth;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -38,6 +37,8 @@ import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
/**
* Dialog fragment for renaming a Bluetooth device.
*/

View File

@@ -15,7 +15,6 @@
*/
package com.android.settings.bluetooth;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -40,6 +39,7 @@ import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
/**
* A dialogFragment used by {@link BluetoothPairingDialog} to create an appropriately styled dialog

View File

@@ -17,7 +17,6 @@
package com.android.settings.bluetooth;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
@@ -31,6 +30,7 @@ import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
/** Implements an AlertDialog for confirming that a user wishes to unpair or "forget" a paired
* device*/

View File

@@ -18,7 +18,6 @@ package com.android.settings.bluetooth;
import android.annotation.NonNull;
import android.app.Activity;
import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
@@ -38,6 +37,8 @@ import com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver;
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import androidx.appcompat.app.AlertDialog;
/**
* RequestPermissionActivity asks the user whether to enable discovery. This is
* usually started by an application wanted to start bluetooth and or discovery

View File

@@ -16,7 +16,6 @@
package com.android.settings.bluetooth;
import android.app.AlertDialog;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
@@ -34,6 +33,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothManager.BluetoothManagerCallback;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
/**
* Utils is a helper class that contains constants for various

View File

@@ -35,15 +35,14 @@ import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.widget.Toolbar;
import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
import com.android.settingslib.drawer.CategoryManager;
import com.android.settingslib.drawer.TileUtils;
import java.util.ArrayList;
import java.util.List;
import androidx.fragment.app.FragmentActivity;
public class SettingsBaseActivity extends FragmentActivity {
protected static final boolean DEBUG_TIMING = false;
@@ -174,7 +173,7 @@ public class SettingsBaseActivity extends FragmentActivity {
}
public String getSettingPkg() {
return TileUtils.SETTING_PKG;
return CategoryManager.SETTING_PKG;
}
public interface CategoryListener {

View File

@@ -20,6 +20,9 @@ import android.graphics.drawable.Drawable;
import android.service.settings.suggestions.Suggestion;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
import androidx.recyclerview.widget.DiffUtil;
import com.android.settings.R;
import com.android.settings.dashboard.conditional.Condition;
import com.android.settingslib.drawer.DashboardCategory;
@@ -31,9 +34,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import androidx.annotation.VisibleForTesting;
import androidx.recyclerview.widget.DiffUtil;
/**
* Description about data list used in the DashboardAdapter. In the data list each item can be
* Condition, suggestion or category tile.
@@ -411,16 +411,7 @@ public class DashboardData {
&& TextUtils.equals(localTile.summary, targetTile.summary);
case TYPE_SUGGESTION_CONTAINER:
case TYPE_CONDITION_CONTAINER:
// If entity is suggestion and contains remote view, force refresh
final List entities = (List) entity;
if (!entities.isEmpty()) {
Object firstEntity = entities.get(0);
if (firstEntity instanceof Tile
&& ((Tile) firstEntity).remoteViews != null) {
return false;
}
}
// Otherwise Fall through to default
// Fall through to default
default:
return entity == null ? targetItem.entity == null
: entity.equals(targetItem.entity);

View File

@@ -19,7 +19,6 @@ package com.android.settings.dashboard;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -37,6 +36,8 @@ import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
import com.android.settingslib.RestrictedLockUtils;
import androidx.appcompat.app.AlertDialog;
/**
* Base class for settings screens that should be pin protected when in restricted mode or
* that will display an admin support message in case an admin has disabled the options.

View File

@@ -17,7 +17,6 @@ package com.android.settings.datausage;
import static android.net.NetworkPolicy.LIMIT_DISABLED;
import static android.net.NetworkPolicy.WARNING_DISABLED;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -47,6 +46,7 @@ import java.util.ArrayList;
import java.util.List;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;

View File

@@ -16,12 +16,12 @@
package com.android.settings.deletionhelper;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import com.android.settings.R;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
/**

View File

@@ -16,7 +16,6 @@
package com.android.settings.development;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -26,6 +25,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
public class BluetoothA2dpHwOffloadRebootDialog extends InstrumentedDialogFragment

View File

@@ -16,7 +16,6 @@
package com.android.settings.development;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

View File

@@ -16,7 +16,6 @@
package com.android.settings.development;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

View File

@@ -16,7 +16,6 @@
package com.android.settings.development;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

View File

@@ -16,7 +16,6 @@
package com.android.settings.development;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
public class EnableDevelopmentSettingWarningDialog extends InstrumentedDialogFragment

View File

@@ -16,7 +16,6 @@
package com.android.settings.development;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

View File

@@ -16,7 +16,6 @@
package com.android.settings.development;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
@@ -24,6 +23,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

View File

@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Build;
import android.os.Bundle;
@@ -31,6 +30,7 @@ import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {

View File

@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -38,6 +37,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.search.actionbar.SearchMenuController;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class PrivateVolumeForget extends InstrumentedFragment {

View File

@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -65,6 +64,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;

View File

@@ -18,7 +18,6 @@ package com.android.settings.deviceinfo;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -61,6 +60,7 @@ import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;

View File

@@ -20,7 +20,6 @@ import static android.os.storage.DiskInfo.EXTRA_DISK_ID;
import static com.android.settings.deviceinfo.StorageWizardBase.EXTRA_FORMAT_FORGET_UUID;
import static com.android.settings.deviceinfo.StorageWizardBase.EXTRA_FORMAT_PRIVATE;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
@@ -33,6 +32,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
public class StorageWizardFormatConfirm extends InstrumentedDialogFragment {

View File

@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo.aboutphone;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
/**

View File

@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo.firmwareversion;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -27,6 +26,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

View File

@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo.imei;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.text.TextUtils;
@@ -30,6 +29,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

View File

@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo.simstatus;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.text.TextUtils;
@@ -28,6 +27,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

View File

@@ -17,7 +17,6 @@
package com.android.settings.enterprise;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
@@ -43,6 +42,7 @@ import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import java.util.Objects;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
/**
* Helper class for {@link ActionDisabledByAdminDialog} which sets up the dialog.

View File

@@ -16,7 +16,6 @@
package com.android.settings.fuelgauge;
import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.Dialog;
import android.content.Context;
@@ -38,6 +37,7 @@ import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class HighPowerDetail extends InstrumentedDialogFragment implements OnClickListener,

View File

@@ -16,7 +16,6 @@
package com.android.settings.fuelgauge.batterytip;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -39,6 +38,7 @@ import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
import java.util.List;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

View File

@@ -40,6 +40,7 @@ public class BatteryTipPolicy {
private static final String KEY_HIGH_USAGE_PERIOD_MS = "high_usage_period_ms";
private static final String KEY_HIGH_USAGE_BATTERY_DRAINING = "high_usage_battery_draining";
private static final String KEY_APP_RESTRICTION_ENABLED = "app_restriction_enabled";
private static final String KEY_APP_RESTRICTION_ACTIVE_HOUR = "app_restriction_active_hour";
private static final String KEY_REDUCED_BATTERY_ENABLED = "reduced_battery_enabled";
private static final String KEY_REDUCED_BATTERY_PERCENT = "reduced_battery_percent";
private static final String KEY_LOW_BATTERY_ENABLED = "low_battery_enabled";
@@ -118,6 +119,15 @@ public class BatteryTipPolicy {
*/
public final boolean appRestrictionEnabled;
/**
* Period(hour) to show anomaly apps. If it is 24 hours, it means only show anomaly apps
* happened in last 24 hours.
*
* @see Settings.Global#BATTERY_TIP_CONSTANTS
* @see #KEY_APP_RESTRICTION_ACTIVE_HOUR
*/
public final int appRestrictionActiveHour;
/**
* {@code true} if reduced battery tip is enabled
*
@@ -228,6 +238,7 @@ public class BatteryTipPolicy {
Duration.ofHours(2).toMillis());
highUsageBatteryDraining = mParser.getInt(KEY_HIGH_USAGE_BATTERY_DRAINING, 25);
appRestrictionEnabled = mParser.getBoolean(KEY_APP_RESTRICTION_ENABLED, true);
appRestrictionActiveHour = mParser.getInt(KEY_APP_RESTRICTION_ACTIVE_HOUR, 24);
reducedBatteryEnabled = mParser.getBoolean(KEY_REDUCED_BATTERY_ENABLED, false);
reducedBatteryPercent = mParser.getInt(KEY_REDUCED_BATTERY_PERCENT, 50);
lowBatteryEnabled = mParser.getBoolean(KEY_LOW_BATTERY_ENABLED, true);

View File

@@ -136,8 +136,8 @@ public class BatteryTipUtils {
final List<AppInfo> highUsageApps = BatteryDatabaseManager.getInstance(context)
.queryAllAnomalies(timeAfterMs, AnomalyDatabaseHelper.State.NEW);
// Remove it if it doesn't have label or been restricted
highUsageApps.removeIf(
new AppLabelPredicate(context).or(new AppRestrictionPredicate(context)));
highUsageApps.removeIf(AppLabelPredicate.getInstance(context)
.or(AppRestrictionPredicate.getInstance(context)));
return highUsageApps;
}

View File

@@ -31,6 +31,7 @@ import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import androidx.annotation.VisibleForTesting;
@@ -53,8 +54,8 @@ public class RestrictAppDetector implements BatteryTipDetector {
mContext = context;
mPolicy = policy;
mBatteryDatabaseManager = BatteryDatabaseManager.getInstance(context);
mAppRestrictionPredicate = new AppRestrictionPredicate(context);
mAppLabelPredicate = new AppLabelPredicate(context);
mAppRestrictionPredicate = AppRestrictionPredicate.getInstance(context);
mAppLabelPredicate = AppLabelPredicate.getInstance(context);
}
@Override
@@ -63,8 +64,8 @@ public class RestrictAppDetector implements BatteryTipDetector {
return getFakeData();
}
if (mPolicy.appRestrictionEnabled) {
// TODO(b/80192137): hook up the query timestamp to server side
final long oneDayBeforeMs = System.currentTimeMillis() - DateUtils.DAY_IN_MILLIS;
final long oneDayBeforeMs = System.currentTimeMillis()
- TimeUnit.HOURS.toMillis(mPolicy.appRestrictionActiveHour);
final List<AppInfo> highUsageApps = BatteryTipUtils.detectAnomalies(mContext,
oneDayBeforeMs);
if (!highUsageApps.isEmpty()) {

View File

@@ -16,7 +16,6 @@
package com.android.settings.fuelgauge.batterytip.tips;
import android.app.AppOpsManager;
import android.content.Context;
import com.android.settings.Utils;
@@ -28,12 +27,20 @@ import java.util.function.Predicate;
* {@link Predicate} for {@link AppInfo} to check whether it has label
*/
public class AppLabelPredicate implements Predicate<AppInfo> {
private Context mContext;
private AppOpsManager mAppOpsManager;
public AppLabelPredicate(Context context) {
private static AppLabelPredicate sInstance;
private Context mContext;
public static AppLabelPredicate getInstance(Context context) {
if (sInstance == null) {
sInstance = new AppLabelPredicate(context.getApplicationContext());
}
return sInstance;
}
private AppLabelPredicate(Context context) {
mContext = context;
mAppOpsManager = context.getSystemService(AppOpsManager.class);
}
@Override

View File

@@ -27,9 +27,19 @@ import java.util.function.Predicate;
* {@link Predicate} for {@link AppInfo} to check whether it is restricted.
*/
public class AppRestrictionPredicate implements Predicate<AppInfo> {
private static AppRestrictionPredicate sInstance;
private AppOpsManager mAppOpsManager;
public AppRestrictionPredicate(Context context) {
public static AppRestrictionPredicate getInstance(Context context) {
if (sInstance == null) {
sInstance = new AppRestrictionPredicate(context.getApplicationContext());
}
return sInstance;
}
private AppRestrictionPredicate(Context context) {
mAppOpsManager = context.getSystemService(AppOpsManager.class);
}

View File

@@ -16,7 +16,6 @@
package com.android.settings.fuelgauge.batterytip.tips;
import android.content.ContentResolver;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;

View File

@@ -112,7 +112,7 @@ public class RestrictAppTip extends BatteryTip {
super.sanityCheck(context);
// Set it invisible if there is no valid app
mRestrictAppList.removeIf(new AppLabelPredicate(context));
mRestrictAppList.removeIf(AppLabelPredicate.getInstance(context));
if (mRestrictAppList.isEmpty()) {
mState = StateType.INVISIBLE;
}

View File

@@ -17,7 +17,6 @@
package com.android.settings.inputmethod;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -43,6 +42,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import java.util.ArrayList;
import java.util.Collections;
import androidx.appcompat.app.AlertDialog;
import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.loader.content.AsyncTaskLoader;
import androidx.loader.content.Loader;

View File

@@ -16,7 +16,6 @@
package com.android.settings.inputmethod;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.ApplicationInfo;
@@ -35,6 +34,7 @@ import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.SwitchBar.OnSwitchChangeListener;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.Preference.OnPreferenceClickListener;

View File

@@ -19,7 +19,6 @@ package com.android.settings.localepicker;
import static android.os.UserManager.DISALLOW_CONFIG_LOCALE;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
@@ -42,6 +41,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;
/**

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.location;
import android.content.Context;
import android.text.TextUtils;
import androidx.preference.Preference;
import com.android.settings.widget.AppPreference;
import com.android.settings.widget.RestrictedAppPreference;
import com.android.settingslib.location.InjectedSetting;
import com.android.settingslib.location.SettingsInjector;
import java.util.List;
/**
* Adds the preferences specified by the {@link InjectedSetting} objects to a preference group.
*/
public class AppSettingsInjector extends SettingsInjector {
public AppSettingsInjector(Context context) {
super(context);
}
@Override
protected Preference createPreference(Context prefContext, InjectedSetting setting) {
return TextUtils.isEmpty(setting.userRestriction)
? new AppPreference(prefContext)
: new RestrictedAppPreference(prefContext, setting.userRestriction);
}
}

View File

@@ -1,191 +0,0 @@
/*
* Copyright (C) 2013 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.location;
import android.content.Intent;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Log;
import com.android.internal.annotations.Immutable;
import java.util.Objects;
/**
* Specifies a setting that is being injected into Settings &gt; Location &gt; Location services.
*
* @see android.location.SettingInjectorService
*/
@Immutable
class InjectedSetting {
/**
* Package for the subclass of {@link android.location.SettingInjectorService} and for the
* settings activity.
*/
public final String packageName;
/**
* Class name for the subclass of {@link android.location.SettingInjectorService} that
* specifies dynamic values for the location setting.
*/
public final String className;
/**
* The {@link androidx.preference.Preference#getTitle()} value.
*/
public final String title;
/**
* The {@link androidx.preference.Preference#getIcon()} value.
*/
public final int iconId;
/**
* The user/profile associated with this setting (e.g. managed profile)
*/
public final UserHandle mUserHandle;
/**
* The activity to launch to allow the user to modify the settings value. Assumed to be in the
* {@link #packageName} package.
*/
public final String settingsActivity;
/**
* The user restriction associated with this setting.
*/
public final String userRestriction;
private InjectedSetting(Builder builder) {
this.packageName = builder.mPackageName;
this.className = builder.mClassName;
this.title = builder.mTitle;
this.iconId = builder.mIconId;
this.mUserHandle = builder.mUserHandle;
this.settingsActivity = builder.mSettingsActivity;
this.userRestriction = builder.mUserRestriction;
}
@Override
public String toString() {
return "InjectedSetting{" +
"mPackageName='" + packageName + '\'' +
", mClassName='" + className + '\'' +
", label=" + title +
", iconId=" + iconId +
", userId=" + mUserHandle.getIdentifier() +
", settingsActivity='" + settingsActivity + '\'' +
", userRestriction='" + userRestriction +
'}';
}
/**
* Returns the intent to start the {@link #className} service.
*/
public Intent getServiceIntent() {
Intent intent = new Intent();
intent.setClassName(packageName, className);
return intent;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof InjectedSetting)) return false;
InjectedSetting that = (InjectedSetting) o;
return Objects.equals(packageName, that.packageName)
&& Objects.equals(className, that.className)
&& Objects.equals(title, that.title)
&& Objects.equals(iconId, that.iconId)
&& Objects.equals(mUserHandle, that.mUserHandle)
&& Objects.equals(settingsActivity, that.settingsActivity)
&& Objects.equals(userRestriction, that.userRestriction);
}
@Override
public int hashCode() {
int result = packageName.hashCode();
result = 31 * result + className.hashCode();
result = 31 * result + title.hashCode();
result = 31 * result + iconId;
result = 31 * result + (mUserHandle == null ? 0 : mUserHandle.hashCode());
result = 31 * result + settingsActivity.hashCode();
result = 31 * result + (userRestriction == null ? 0 : userRestriction.hashCode());
return result;
}
public static class Builder {
private String mPackageName;
private String mClassName;
private String mTitle;
private int mIconId;
private UserHandle mUserHandle;
private String mSettingsActivity;
private String mUserRestriction;
public Builder setPackageName(String packageName) {
mPackageName = packageName;
return this;
}
public Builder setClassName(String className) {
mClassName = className;
return this;
}
public Builder setTitle(String title) {
mTitle = title;
return this;
}
public Builder setIconId(int iconId) {
mIconId = iconId;
return this;
}
public Builder setUserHandle(UserHandle userHandle) {
mUserHandle = userHandle;
return this;
}
public Builder setSettingsActivity(String settingsActivity) {
mSettingsActivity = settingsActivity;
return this;
}
public Builder setUserRestriction(String userRestriction) {
mUserRestriction = userRestriction;
return this;
}
public InjectedSetting build() {
if (mPackageName == null || mClassName == null || TextUtils.isEmpty(mTitle)
|| TextUtils.isEmpty(mSettingsActivity)) {
if (Log.isLoggable(SettingsInjector.TAG, Log.WARN)) {
Log.w(SettingsInjector.TAG, "Illegal setting specification: package="
+ mPackageName + ", class=" + mClassName
+ ", title=" + mTitle + ", settingsActivity=" + mSettingsActivity);
}
return null;
}
return new InjectedSetting(this);
}
}
}

View File

@@ -47,19 +47,19 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
private PreferenceCategory mCategoryLocationServices;
private final LocationSettings mFragment;
private final SettingsInjector mInjector;
private final AppSettingsInjector mInjector;
/** Receives UPDATE_INTENT */
@VisibleForTesting
BroadcastReceiver mInjectedSettingsReceiver;
public LocationServicePreferenceController(Context context, LocationSettings fragment,
Lifecycle lifecycle) {
this(context, fragment, lifecycle, new SettingsInjector(context));
this(context, fragment, lifecycle, new AppSettingsInjector(context));
}
@VisibleForTesting
LocationServicePreferenceController(Context context, LocationSettings fragment,
Lifecycle lifecycle, SettingsInjector injector) {
Lifecycle lifecycle, AppSettingsInjector injector) {
super(context, lifecycle);
mFragment = fragment;
mInjector = injector;

View File

@@ -1,577 +0,0 @@
/*
* Copyright (C) 2013 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.location;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
import android.location.SettingInjectorService;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.IconDrawableFactory;
import android.util.Log;
import android.util.Xml;
import com.android.settings.widget.AppPreference;
import com.android.settings.widget.RestrictedAppPreference;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import androidx.preference.Preference;
/**
* Adds the preferences specified by the {@link InjectedSetting} objects to a preference group.
*
* Duplicates some code from {@link android.content.pm.RegisteredServicesCache}. We do not use that
* class directly because it is not a good match for our use case: we do not need the caching, and
* so do not want the additional resource hit at app install/upgrade time; and we would have to
* suppress the tie-breaking between multiple services reporting settings with the same name.
* Code-sharing would require extracting {@link
* android.content.pm.RegisteredServicesCache#parseServiceAttributes(android.content.res.Resources,
* String, android.util.AttributeSet)} into an interface, which didn't seem worth it.
*/
class SettingsInjector {
static final String TAG = "SettingsInjector";
/**
* If reading the status of a setting takes longer than this, we go ahead and start reading
* the next setting.
*/
private static final long INJECTED_STATUS_UPDATE_TIMEOUT_MILLIS = 1000;
/**
* {@link Message#what} value for starting to load status values
* in case we aren't already in the process of loading them.
*/
private static final int WHAT_RELOAD = 1;
/**
* {@link Message#what} value sent after receiving a status message.
*/
private static final int WHAT_RECEIVED_STATUS = 2;
/**
* {@link Message#what} value sent after the timeout waiting for a status message.
*/
private static final int WHAT_TIMEOUT = 3;
private final Context mContext;
/**
* The settings that were injected
*/
private final Set<Setting> mSettings;
private final Handler mHandler;
public SettingsInjector(Context context) {
mContext = context;
mSettings = new HashSet<Setting>();
mHandler = new StatusLoadingHandler();
}
/**
* Returns a list for a profile with one {@link InjectedSetting} object for each
* {@link android.app.Service} that responds to
* {@link SettingInjectorService#ACTION_SERVICE_INTENT} and provides the expected setting
* metadata.
*
* Duplicates some code from {@link android.content.pm.RegisteredServicesCache}.
*
* TODO: unit test
*/
private List<InjectedSetting> getSettings(final UserHandle userHandle) {
PackageManager pm = mContext.getPackageManager();
Intent intent = new Intent(SettingInjectorService.ACTION_SERVICE_INTENT);
final int profileId = userHandle.getIdentifier();
List<ResolveInfo> resolveInfos =
pm.queryIntentServicesAsUser(intent, PackageManager.GET_META_DATA, profileId);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Found services for profile id " + profileId + ": " + resolveInfos);
}
List<InjectedSetting> settings = new ArrayList<InjectedSetting>(resolveInfos.size());
for (ResolveInfo resolveInfo : resolveInfos) {
try {
InjectedSetting setting = parseServiceInfo(resolveInfo, userHandle, pm);
if (setting == null) {
Log.w(TAG, "Unable to load service info " + resolveInfo);
} else {
settings.add(setting);
}
} catch (XmlPullParserException e) {
Log.w(TAG, "Unable to load service info " + resolveInfo, e);
} catch (IOException e) {
Log.w(TAG, "Unable to load service info " + resolveInfo, e);
}
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Loaded settings for profile id " + profileId + ": " + settings);
}
return settings;
}
/**
* Returns the settings parsed from the attributes of the
* {@link SettingInjectorService#META_DATA_NAME} tag, or null.
*
* Duplicates some code from {@link android.content.pm.RegisteredServicesCache}.
*/
private static InjectedSetting parseServiceInfo(ResolveInfo service, UserHandle userHandle,
PackageManager pm) throws XmlPullParserException, IOException {
ServiceInfo si = service.serviceInfo;
ApplicationInfo ai = si.applicationInfo;
if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
if (Log.isLoggable(TAG, Log.WARN)) {
Log.w(TAG, "Ignoring attempt to inject setting from app not in system image: "
+ service);
return null;
}
}
XmlResourceParser parser = null;
try {
parser = si.loadXmlMetaData(pm, SettingInjectorService.META_DATA_NAME);
if (parser == null) {
throw new XmlPullParserException("No " + SettingInjectorService.META_DATA_NAME
+ " meta-data for " + service + ": " + si);
}
AttributeSet attrs = Xml.asAttributeSet(parser);
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& type != XmlPullParser.START_TAG) {
}
String nodeName = parser.getName();
if (!SettingInjectorService.ATTRIBUTES_NAME.equals(nodeName)) {
throw new XmlPullParserException("Meta-data does not start with "
+ SettingInjectorService.ATTRIBUTES_NAME + " tag");
}
Resources res = pm.getResourcesForApplicationAsUser(si.packageName,
userHandle.getIdentifier());
return parseAttributes(si.packageName, si.name, userHandle, res, attrs);
} catch (PackageManager.NameNotFoundException e) {
throw new XmlPullParserException(
"Unable to load resources for package " + si.packageName);
} finally {
if (parser != null) {
parser.close();
}
}
}
/**
* Returns an immutable representation of the static attributes for the setting, or null.
*/
private static InjectedSetting parseAttributes(String packageName, String className,
UserHandle userHandle, Resources res, AttributeSet attrs) {
TypedArray sa = res.obtainAttributes(attrs, android.R.styleable.SettingInjectorService);
try {
// Note that to help guard against malicious string injection, we do not allow dynamic
// specification of the label (setting title)
final String title = sa.getString(android.R.styleable.SettingInjectorService_title);
final int iconId =
sa.getResourceId(android.R.styleable.SettingInjectorService_icon, 0);
final String settingsActivity =
sa.getString(android.R.styleable.SettingInjectorService_settingsActivity);
final String userRestriction = sa.getString(
android.R.styleable.SettingInjectorService_userRestriction);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "parsed title: " + title + ", iconId: " + iconId
+ ", settingsActivity: " + settingsActivity);
}
return new InjectedSetting.Builder()
.setPackageName(packageName)
.setClassName(className)
.setTitle(title)
.setIconId(iconId)
.setUserHandle(userHandle)
.setSettingsActivity(settingsActivity)
.setUserRestriction(userRestriction)
.build();
} finally {
sa.recycle();
}
}
/**
* Gets a list of preferences that other apps have injected.
*
* @param profileId Identifier of the user/profile to obtain the injected settings for or
* UserHandle.USER_CURRENT for all profiles associated with current user.
*/
public List<Preference> getInjectedSettings(Context prefContext, final int profileId) {
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
final List<UserHandle> profiles = um.getUserProfiles();
ArrayList<Preference> prefs = new ArrayList<>();
final int profileCount = profiles.size();
for (int i = 0; i < profileCount; ++i) {
final UserHandle userHandle = profiles.get(i);
if (profileId == UserHandle.USER_CURRENT || profileId == userHandle.getIdentifier()) {
Iterable<InjectedSetting> settings = getSettings(userHandle);
for (InjectedSetting setting : settings) {
Preference pref = addServiceSetting(prefContext, prefs, setting);
mSettings.add(new Setting(setting, pref));
}
}
}
reloadStatusMessages();
return prefs;
}
/**
* Checks wheteher there is any preference that other apps have injected.
*
* @param profileId Identifier of the user/profile to obtain the injected settings for or
* UserHandle.USER_CURRENT for all profiles associated with current user.
*/
public boolean hasInjectedSettings(final int profileId) {
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
final List<UserHandle> profiles = um.getUserProfiles();
final int profileCount = profiles.size();
for (int i = 0; i < profileCount; ++i) {
final UserHandle userHandle = profiles.get(i);
if (profileId == UserHandle.USER_CURRENT || profileId == userHandle.getIdentifier()) {
Iterable<InjectedSetting> settings = getSettings(userHandle);
for (InjectedSetting setting : settings) {
return true;
}
}
}
return false;
}
/**
* Reloads the status messages for all the preference items.
*/
public void reloadStatusMessages() {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "reloadingStatusMessages: " + mSettings);
}
mHandler.sendMessage(mHandler.obtainMessage(WHAT_RELOAD));
}
/**
* Adds an injected setting to the root.
*/
private Preference addServiceSetting(Context prefContext, List<Preference> prefs,
InjectedSetting info) {
final PackageManager pm = mContext.getPackageManager();
Drawable appIcon = null;
try {
final PackageItemInfo itemInfo = new PackageItemInfo();
itemInfo.icon = info.iconId;
itemInfo.packageName = info.packageName;
final ApplicationInfo appInfo = pm.getApplicationInfo(info.packageName,
PackageManager.GET_META_DATA);
appIcon = IconDrawableFactory.newInstance(mContext)
.getBadgedIcon(itemInfo, appInfo, info.mUserHandle.getIdentifier());
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Can't get ApplicationInfo for " + info.packageName, e);
}
Preference pref = TextUtils.isEmpty(info.userRestriction)
? new AppPreference(prefContext)
: new RestrictedAppPreference(prefContext, info.userRestriction);
pref.setTitle(info.title);
pref.setSummary(null);
pref.setIcon(appIcon);
pref.setOnPreferenceClickListener(new ServiceSettingClickedListener(info));
prefs.add(pref);
return pref;
}
private class ServiceSettingClickedListener
implements Preference.OnPreferenceClickListener {
private InjectedSetting mInfo;
public ServiceSettingClickedListener(InjectedSetting info) {
mInfo = info;
}
@Override
public boolean onPreferenceClick(Preference preference) {
// Activity to start if they click on the preference. Must start in new task to ensure
// that "android.settings.LOCATION_SOURCE_SETTINGS" brings user back to
// Settings > Location.
Intent settingIntent = new Intent();
settingIntent.setClassName(mInfo.packageName, mInfo.settingsActivity);
// Sometimes the user may navigate back to "Settings" and launch another different
// injected setting after one injected setting has been launched.
//
// FLAG_ACTIVITY_CLEAR_TOP allows multiple Activities to stack on each other. When
// "back" button is clicked, the user will navigate through all the injected settings
// launched before. Such behavior could be quite confusing sometimes.
//
// In order to avoid such confusion, we use FLAG_ACTIVITY_CLEAR_TASK, which always clear
// up all existing injected settings and make sure that "back" button always brings the
// user back to "Settings" directly.
settingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
mContext.startActivityAsUser(settingIntent, mInfo.mUserHandle);
return true;
}
}
/**
* Loads the setting status values one at a time. Each load starts a subclass of {@link
* SettingInjectorService}, so to reduce memory pressure we don't want to load too many at
* once.
*/
private final class StatusLoadingHandler extends Handler {
/**
* Settings whose status values need to be loaded. A set is used to prevent redundant loads.
*/
private Set<Setting> mSettingsToLoad = new HashSet<Setting>();
/**
* Settings that are being loaded now and haven't timed out. In practice this should have
* zero or one elements.
*/
private Set<Setting> mSettingsBeingLoaded = new HashSet<Setting>();
/**
* Settings that are being loaded but have timed out. If only one setting has timed out, we
* will go ahead and start loading the next setting so that one slow load won't delay the
* load of the other settings.
*/
private Set<Setting> mTimedOutSettings = new HashSet<Setting>();
private boolean mReloadRequested;
private StatusLoadingHandler() {
super(Looper.getMainLooper());
}
@Override
public void handleMessage(Message msg) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "handleMessage start: " + msg + ", " + this);
}
// Update state in response to message
switch (msg.what) {
case WHAT_RELOAD:
mReloadRequested = true;
break;
case WHAT_RECEIVED_STATUS:
final Setting receivedSetting = (Setting) msg.obj;
receivedSetting.maybeLogElapsedTime();
mSettingsBeingLoaded.remove(receivedSetting);
mTimedOutSettings.remove(receivedSetting);
removeMessages(WHAT_TIMEOUT, receivedSetting);
break;
case WHAT_TIMEOUT:
final Setting timedOutSetting = (Setting) msg.obj;
mSettingsBeingLoaded.remove(timedOutSetting);
mTimedOutSettings.add(timedOutSetting);
if (Log.isLoggable(TAG, Log.WARN)) {
Log.w(TAG, "Timed out after " + timedOutSetting.getElapsedTime()
+ " millis trying to get status for: " + timedOutSetting);
}
break;
default:
Log.wtf(TAG, "Unexpected what: " + msg);
}
// Decide whether to load additional settings based on the new state. Start by seeing
// if we have headroom to load another setting.
if (mSettingsBeingLoaded.size() > 0 || mTimedOutSettings.size() > 1) {
// Don't load any more settings until one of the pending settings has completed.
// To reduce memory pressure, we want to be loading at most one setting (plus at
// most one timed-out setting) at a time. This means we'll be responsible for
// bringing in at most two services.
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "too many services already live for " + msg + ", " + this);
}
return;
}
if (mReloadRequested && mSettingsToLoad.isEmpty() && mSettingsBeingLoaded.isEmpty()
&& mTimedOutSettings.isEmpty()) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "reloading because idle and reload requesteed " + msg + ", " + this);
}
// Reload requested, so must reload all settings
mSettingsToLoad.addAll(mSettings);
mReloadRequested = false;
}
// Remove the next setting to load from the queue, if any
Iterator<Setting> iter = mSettingsToLoad.iterator();
if (!iter.hasNext()) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "nothing left to do for " + msg + ", " + this);
}
return;
}
Setting setting = iter.next();
iter.remove();
// Request the status value
setting.startService();
mSettingsBeingLoaded.add(setting);
// Ensure that if receiving the status value takes too long, we start loading the
// next value anyway
Message timeoutMsg = obtainMessage(WHAT_TIMEOUT, setting);
sendMessageDelayed(timeoutMsg, INJECTED_STATUS_UPDATE_TIMEOUT_MILLIS);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "handleMessage end " + msg + ", " + this
+ ", started loading " + setting);
}
}
@Override
public String toString() {
return "StatusLoadingHandler{" +
"mSettingsToLoad=" + mSettingsToLoad +
", mSettingsBeingLoaded=" + mSettingsBeingLoaded +
", mTimedOutSettings=" + mTimedOutSettings +
", mReloadRequested=" + mReloadRequested +
'}';
}
}
/**
* Represents an injected setting and the corresponding preference.
*/
private final class Setting {
public final InjectedSetting setting;
public final Preference preference;
public long startMillis;
private Setting(InjectedSetting setting, Preference preference) {
this.setting = setting;
this.preference = preference;
}
@Override
public String toString() {
return "Setting{" +
"setting=" + setting +
", preference=" + preference +
'}';
}
/**
* Returns true if they both have the same {@link #setting} value. Ignores mutable
* {@link #preference} and {@link #startMillis} so that it's safe to use in sets.
*/
@Override
public boolean equals(Object o) {
return this == o || o instanceof Setting && setting.equals(((Setting) o).setting);
}
@Override
public int hashCode() {
return setting.hashCode();
}
/**
* Starts the service to fetch for the current status for the setting, and updates the
* preference when the service replies.
*/
public void startService() {
final ActivityManager am = (ActivityManager)
mContext.getSystemService(Context.ACTIVITY_SERVICE);
if (!am.isUserRunning(setting.mUserHandle.getIdentifier())) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Cannot start service as user "
+ setting.mUserHandle.getIdentifier() + " is not running");
}
return;
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Bundle bundle = msg.getData();
boolean enabled = bundle.getBoolean(SettingInjectorService.ENABLED_KEY, true);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, setting + ": received " + msg + ", bundle: " + bundle);
}
preference.setSummary(null);
preference.setEnabled(enabled);
mHandler.sendMessage(
mHandler.obtainMessage(WHAT_RECEIVED_STATUS, Setting.this));
}
};
Messenger messenger = new Messenger(handler);
Intent intent = setting.getServiceIntent();
intent.putExtra(SettingInjectorService.MESSENGER_KEY, messenger);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, setting + ": sending update intent: " + intent
+ ", handler: " + handler);
startMillis = SystemClock.elapsedRealtime();
} else {
startMillis = 0;
}
// Start the service, making sure that this is attributed to the user associated with
// the setting rather than the system user.
mContext.startServiceAsUser(intent, setting.mUserHandle);
}
public long getElapsedTime() {
long end = SystemClock.elapsedRealtime();
return end - startMillis;
}
public void maybeLogElapsedTime() {
if (Log.isLoggable(TAG, Log.DEBUG) && startMillis != 0) {
long elapsed = getElapsedTime();
Log.d(TAG, this + " update took " + elapsed + " millis");
}
}
}
}

View File

@@ -18,7 +18,6 @@ package com.android.settings.network;
import static android.content.Context.TELEPHONY_SERVICE;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentValues;
import android.content.Context;
@@ -55,6 +54,7 @@ import java.util.List;
import java.util.Set;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.MultiSelectListPreference;

View File

@@ -19,7 +19,6 @@ import static com.android.settings.network.MobilePlanPreferenceController
.MANAGE_MOBILE_PLAN_DIALOG_ID;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.icu.text.ListFormatter;
@@ -44,6 +43,7 @@ import java.util.Arrays;
import java.util.List;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
@SearchIndexable

View File

@@ -16,7 +16,6 @@
package com.android.settings.notification;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.NotificationManager;
import android.content.ComponentName;
@@ -42,6 +41,7 @@ import java.util.ArrayList;
import java.util.List;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
/**

View File

@@ -16,7 +16,6 @@
package com.android.settings.notification;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -36,6 +35,7 @@ import com.android.settings.RestrictedListPreference;
import com.android.settings.Utils;
import com.android.settingslib.RestrictedLockUtils;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AlertDialog.Builder;
public class NotificationLockscreenPreference extends RestrictedListPreference {

View File

@@ -17,7 +17,6 @@
package com.android.settings.notification;
import android.annotation.UserIdInt;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -47,6 +46,7 @@ import com.android.settingslib.core.lifecycle.events.OnResume;
import java.util.List;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;

View File

@@ -18,7 +18,6 @@ package com.android.settings.notification;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.AppGlobals;
import android.app.Dialog;
import android.app.NotificationManager;
@@ -58,6 +57,7 @@ import java.util.Collections;
import java.util.List;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceScreen;

View File

@@ -16,7 +16,6 @@
package com.android.settings.notification;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -26,6 +25,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class ZenDeleteRuleDialog extends InstrumentedDialogFragment {

Some files were not shown because too many files have changed in this diff Show More