Merge "Report user selected resolution events to StatsLog"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 37c9a7f..5352562 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -126,7 +126,6 @@
<uses-permission android:name="android.permission.SEND_SAFETY_CENTER_UPDATE" />
<uses-permission android:name="android.permission.START_VIEW_APP_FEATURES" />
<uses-permission android:name="android.permission.ACCESS_KEYGUARD_QUICK_AFFORDANCES" />
- <uses-permission android:name="android.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS" />
<application
android:name=".SettingsApplication"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 20f3178..bf39c8b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4952,8 +4952,6 @@
<string name="battery_not_usage_24hr">No usage for past 24 hr</string>
<!-- Description for no usage time but have battery usage [CHAR LIMIT=120] -->
<string name="battery_usage_without_time"></string>
- <!-- Description for other users aggregated battery usage data [CHAR LIMIT=120] -->
- <string name="battery_usage_other_users">Other users</string>
<!-- Description for battery time left, i.e. 50min Estimated time left. [CHAR LIMIT=80]-->
<string name="estimated_time_left">Estimated time left</string>
@@ -9728,12 +9726,8 @@
<!-- AutoFill strings -->
<!-- Preference label for choosing auto-fill service. [CHAR LIMIT=60] -->
<string name="autofill_app">Autofill service</string>
- <!-- Preference label for choosing auto-fill service. [CHAR LIMIT=60] -->
- <string name="default_autofill_app">Default autofill service</string>
<!-- Preference category for showing auto-fill services with saved passwords. [CHAR LIMIT=60] -->
<string name="autofill_passwords">Passwords</string>
- <!-- Preference category for showing credman services with saved credentials. [CHAR LIMIT=60] -->
- <string name="credman_credentials">Password and identity services</string>
<!-- Summary for passwords settings that shows how many passwords are saved for each autofill
service. [CHAR LIMIT=NONE] -->
<plurals name="autofill_passwords_count">
@@ -9745,8 +9739,6 @@
<string name="autofill_passwords_count_placeholder" translatable="false">\u2014</string>
<!-- Keywords for the auto-fill feature. [CHAR LIMIT=NONE] -->
<string name="autofill_keywords">auto, fill, autofill, password</string>
- <!-- Keywords for the credman feature. [CHAR LIMIT=NONE] -->
- <string name="credman_keywords">credentials, passkey, password</string>
<!-- Message of the warning dialog for setting the auto-fill app. [CHAR_LIMIT=NONE] -->
<string name="autofill_confirmation_message">
@@ -9759,21 +9751,6 @@
]]>
</string>
- <!-- Title of the warning dialog for disabling the credential provider. [CHAR_LIMIT=NONE] -->
- <string name="credman_confirmation_message_title">Turn off %1$s\?</string>
-
- <!-- Message of the warning dialog for disabling the credential provider. [CHAR_LIMIT=NONE] -->
- <string name="credman_confirmation_message">Saved info like addresses or payment methods won\'t be filled in when you sign in. To keep your saved info filled in, set a default autofill service.</string>
-
- <!-- Title of the error dialog when too many credential providers are selected. [CHAR_LIMIT=NONE] -->
- <string name="credman_error_message_title">Password and identity services limit</string>
-
- <!-- Message of the error dialog when too many credential providers are selected. [CHAR_LIMIT=NONE] -->
- <string name="credman_error_message">You can have up to 5 autofill and password services active at the same time. Turn off a service to add more.</string>
-
- <!-- Positive button to turn off credential manager provider (confirmation). [CHAR LIMIT=60] -->
- <string name="credman_confirmation_message_positive_button">Turn off</string>
-
<!-- Preference category for autofill debugging development settings. [CHAR LIMIT=25] -->
<string name="debug_autofill_category">Autofill</string>
diff --git a/res/xml/accounts_dashboard_settings_credman.xml b/res/xml/accounts_dashboard_settings_credman.xml
deleted file mode 100644
index 605d315..0000000
--- a/res/xml/accounts_dashboard_settings_credman.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2022 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.
--->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="user_and_account_settings_screen"
- android:title="@string/account_dashboard_title"
- settings:keywords="@string/keywords_accounts">
-
- <PreferenceCategory
- android:key="default_service_category"
- android:order="10"
- android:title="@string/default_autofill_app">
-
- <com.android.settings.widget.GearPreference
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- android:key="default_autofill_main"
- android:title="@string/default_autofill_app"
- settings:keywords="@string/autofill_keywords">
- <extra
- android:name="for_work"
- android:value="false" />
- </com.android.settings.widget.GearPreference>
- </PreferenceCategory>
-
- <PreferenceCategory
- android:key="credman_category"
- android:order="20"
- android:persistent="false"
- android:title="@string/credman_credentials"
- settings:controller="com.android.settings.applications.credentials.CredentialManagerPreferenceController"
- settings:keywords="@string/credman_keywords" />
-
- <PreferenceCategory
- android:key="passwords_category"
- android:order="30"
- android:persistent="false"
- settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
- settings:keywords="@string/autofill_keywords" />
-
- <PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="130"/>
-
- <SwitchPreference
- android:key="auto_sync_account_data"
- android:title="@string/auto_sync_account_title"
- android:summary="@string/auto_sync_account_summary"
- android:order="202"
- settings:allowDividerAbove="true"/>
-
- <SwitchPreference
- android:key="auto_sync_work_account_data"
- android:title="@string/account_settings_menu_auto_sync_work"
- android:summary="@string/auto_sync_account_summary"
- settings:forWork="true"
- android:order="203"/>
-
- <SwitchPreference
- android:key="auto_sync_personal_account_data"
- android:title="@string/account_settings_menu_auto_sync_personal"
- android:summary="@string/auto_sync_account_summary"
- android:order="204"/>
-
-</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/accounts_personal_dashboard_settings_credman.xml b/res/xml/accounts_personal_dashboard_settings_credman.xml
deleted file mode 100644
index a5188dd..0000000
--- a/res/xml/accounts_personal_dashboard_settings_credman.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2022 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.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="user_and_account_settings_screen"
- android:title="@string/account_dashboard_title"
- settings:keywords="@string/keywords_accounts">
-
- <PreferenceCategory
- android:key="default_service_category"
- android:order="10"
- android:title="@string/default_autofill_app">
-
- <com.android.settings.widget.GearPreference
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- android:key="default_autofill_main"
- android:title="@string/default_autofill_app"
- settings:keywords="@string/autofill_keywords">
- <extra
- android:name="for_work"
- android:value="false" />
- </com.android.settings.widget.GearPreference>
- </PreferenceCategory>
-
- <PreferenceCategory
- android:key="credman_category"
- android:order="20"
- android:persistent="false"
- android:title="@string/credman_credentials"
- settings:controller="com.android.settings.applications.credentials.CredentialManagerPreferenceController"
- settings:keywords="@string/credman_keywords" />
-
- <PreferenceCategory
- android:key="passwords_category"
- android:order="30"
- android:persistent="false"
- settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
- settings:keywords="@string/autofill_keywords" />
-
- <PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="130"/>
-
- <SwitchPreference
- android:key="auto_sync_account_data"
- android:title="@string/auto_sync_account_title"
- android:summary="@string/auto_sync_account_summary"
- android:order="200"
- settings:allowDividerAbove="true"/>
-
- <SwitchPreference
- android:key="auto_sync_personal_account_data"
- android:title="@string/account_settings_menu_auto_sync_personal"
- android:summary="@string/auto_sync_account_summary"
- android:order="210"/>
-
-</PreferenceScreen>
diff --git a/res/xml/accounts_work_dashboard_settings_credman.xml b/res/xml/accounts_work_dashboard_settings_credman.xml
deleted file mode 100644
index f4e8af2..0000000
--- a/res/xml/accounts_work_dashboard_settings_credman.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2022 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.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="user_and_account_settings_screen"
- android:title="@string/account_dashboard_title"
- settings:keywords="@string/keywords_accounts">
-
- <com.android.settings.widget.WorkOnlyCategory
- android:key="autofill_work_app_defaults"
- android:order="30"
- android:title="@string/default_autofill_app">
-
- <com.android.settings.widget.GearPreference
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- android:key="default_autofill_work"
- android:title="@string/default_autofill_app"
- settings:searchable="false">
- <extra
- android:name="for_work"
- android:value="true" />
- </com.android.settings.widget.GearPreference>
- </com.android.settings.widget.WorkOnlyCategory>
-
- <PreferenceCategory
- android:key="credman_category"
- android:order="20"
- android:persistent="false"
- android:title="@string/credman_credentials"
- settings:controller="com.android.settings.applications.credentials.CredentialManagerPreferenceController"
- settings:keywords="@string/credman_keywords" />
-
- <PreferenceCategory
- android:key="passwords_category"
- android:order="30"
- android:persistent="false"
- settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
- settings:keywords="@string/autofill_keywords" />
-
- <PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="130"/>
-
- <SwitchPreference
- android:key="auto_sync_account_data"
- android:title="@string/auto_sync_account_title"
- android:summary="@string/auto_sync_account_summary"
- android:order="200"
- settings:allowDividerAbove="true"/>
-
- <SwitchPreference
- android:key="auto_sync_work_account_data"
- android:title="@string/account_settings_menu_auto_sync_work"
- android:summary="@string/auto_sync_account_summary"
- android:order="210"/>
-
-</PreferenceScreen>
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 107df94..3e83d6f 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -22,13 +22,11 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.pm.UserInfo;
-import android.credentials.CredentialManager;
import android.os.UserHandle;
import android.os.UserManager;
import com.android.settings.R;
import com.android.settings.applications.autofill.PasswordsPreferenceController;
-import com.android.settings.applications.credentials.CredentialManagerPreferenceController;
import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
import com.android.settings.applications.defaultapps.DefaultWorkAutofillPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -49,6 +47,7 @@
private static final String TAG = "AccountDashboardFrag";
+
@Override
public int getMetricsCategory() {
return SettingsEnums.ACCOUNT;
@@ -61,7 +60,7 @@
@Override
protected int getPreferenceScreenResId() {
- return getPreferenceLayoutResId();
+ return R.xml.accounts_dashboard_settings;
}
@Override
@@ -72,12 +71,6 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
- if (CredentialManager.isServiceEnabled()) {
- CredentialManagerPreferenceController cmpp =
- use(CredentialManagerPreferenceController.class);
- cmpp.setParentFragment(this);
- }
-
getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
}
@@ -102,13 +95,11 @@
}
private static void buildAccountPreferenceControllers(
- Context context,
- DashboardFragment parent,
- String[] authorities,
+ Context context, DashboardFragment parent, String[] authorities,
List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
- new AccountPreferenceController(
- context, parent, authorities, ProfileSelectFragment.ProfileType.ALL);
+ new AccountPreferenceController(context, parent, authorities,
+ ProfileSelectFragment.ProfileType.ALL);
if (parent != null) {
parent.getSettingsLifecycle().addObserver(accountPrefController);
}
@@ -118,14 +109,8 @@
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
}
- public static int getPreferenceLayoutResId() {
- return CredentialManager.isServiceEnabled()
- ? R.xml.accounts_dashboard_settings_credman
- : R.xml.accounts_dashboard_settings;
- }
-
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(getPreferenceLayoutResId()) {
+ new BaseSearchIndexProvider(R.xml.accounts_dashboard_settings) {
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
@@ -139,11 +124,11 @@
@SuppressWarnings("MissingSuperCall") // TODO: Fix me
@Override
- public List<SearchIndexableRaw> getDynamicRawDataToIndex(
- Context context, boolean enabled) {
+ public List<SearchIndexableRaw> getDynamicRawDataToIndex(Context context,
+ boolean enabled) {
final List<SearchIndexableRaw> indexRaws = new ArrayList<>();
- final UserManager userManager =
- (UserManager) context.getSystemService(Context.USER_SERVICE);
+ final UserManager userManager = (UserManager) context.getSystemService(
+ Context.USER_SERVICE);
final List<UserInfo> profiles = userManager.getProfiles(UserHandle.myUserId());
for (final UserInfo userInfo : profiles) {
if (userInfo.isManagedProfile()) {
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
index e061102..4661c64 100644
--- a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -22,11 +22,9 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.credentials.CredentialManager;
import com.android.settings.R;
import com.android.settings.applications.autofill.PasswordsPreferenceController;
-import com.android.settings.applications.credentials.CredentialManagerPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.users.AutoSyncDataPreferenceController;
@@ -36,7 +34,9 @@
import java.util.ArrayList;
import java.util.List;
-/** Account Setting page for personal profile. */
+/**
+ * Account Setting page for personal profile.
+ */
public class AccountPersonalDashboardFragment extends DashboardFragment {
private static final String TAG = "AccountPersonalFrag";
@@ -53,9 +53,6 @@
@Override
protected int getPreferenceScreenResId() {
- if (CredentialManager.isServiceEnabled()) {
- return R.xml.accounts_personal_dashboard_settings_credman;
- }
return R.xml.accounts_personal_dashboard_settings;
}
@@ -67,13 +64,6 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
-
- if (CredentialManager.isServiceEnabled()) {
- CredentialManagerPreferenceController cmpp =
- use(CredentialManagerPreferenceController.class);
- cmpp.setParentFragment(this);
- }
-
getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
}
@@ -87,13 +77,11 @@
}
private static void buildAccountPreferenceControllers(
- Context context,
- DashboardFragment parent,
- String[] authorities,
+ Context context, DashboardFragment parent, String[] authorities,
List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
- new AccountPreferenceController(
- context, parent, authorities, ProfileSelectFragment.ProfileType.PERSONAL);
+ new AccountPreferenceController(context, parent, authorities,
+ ProfileSelectFragment.ProfileType.PERSONAL);
if (parent != null) {
parent.getSettingsLifecycle().addObserver(accountPrefController);
}
@@ -103,15 +91,15 @@
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
- // public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- // new BaseSearchIndexProvider(R.xml.accounts_personal_dashboard_settings) {
- //
- // @Override
- // public List<AbstractPreferenceController> createPreferenceControllers(
- // Context context) {
- // ..Add autofill here too..
- // return buildPreferenceControllers(
- // context, null /* parent */, null /* authorities*/);
- // }
- // };
+// public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+// new BaseSearchIndexProvider(R.xml.accounts_personal_dashboard_settings) {
+//
+// @Override
+// public List<AbstractPreferenceController> createPreferenceControllers(
+// Context context) {
+// ..Add autofill here too..
+// return buildPreferenceControllers(
+// context, null /* parent */, null /* authorities*/);
+// }
+// };
}
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
index 027d1f7..f64e041 100644
--- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -22,11 +22,9 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.credentials.CredentialManager;
import com.android.settings.R;
import com.android.settings.applications.autofill.PasswordsPreferenceController;
-import com.android.settings.applications.credentials.CredentialManagerPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.users.AutoSyncDataPreferenceController;
@@ -36,7 +34,9 @@
import java.util.ArrayList;
import java.util.List;
-/** Account Setting page for work profile. */
+/**
+ * Account Setting page for work profile.
+ */
public class AccountWorkProfileDashboardFragment extends DashboardFragment {
private static final String TAG = "AccountWorkProfileFrag";
@@ -53,9 +53,6 @@
@Override
protected int getPreferenceScreenResId() {
- if (CredentialManager.isServiceEnabled()) {
- return R.xml.accounts_work_dashboard_settings_credman;
- }
return R.xml.accounts_work_dashboard_settings;
}
@@ -67,13 +64,6 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
-
- if (CredentialManager.isServiceEnabled()) {
- CredentialManagerPreferenceController cmpp =
- use(CredentialManagerPreferenceController.class);
- cmpp.setParentFragment(this);
- }
-
getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
}
@@ -87,13 +77,11 @@
}
private static void buildAccountPreferenceControllers(
- Context context,
- DashboardFragment parent,
- String[] authorities,
+ Context context, DashboardFragment parent, String[] authorities,
List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
- new AccountPreferenceController(
- context, parent, authorities, ProfileSelectFragment.ProfileType.WORK);
+ new AccountPreferenceController(context, parent, authorities,
+ ProfileSelectFragment.ProfileType.WORK);
if (parent != null) {
parent.getSettingsLifecycle().addObserver(accountPrefController);
}
@@ -103,15 +91,15 @@
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
- // public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- // new BaseSearchIndexProvider(R.xml.accounts_work_dashboard_settings) {
- //
- // @Override
- // public List<AbstractPreferenceController> createPreferenceControllers(
- // Context context) {
- // ..Add autofill here too..
- // return buildPreferenceControllers(
- // context, null /* parent */, null /* authorities*/);
- // }
- // };
+// public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+// new BaseSearchIndexProvider(R.xml.accounts_work_dashboard_settings) {
+//
+// @Override
+// public List<AbstractPreferenceController> createPreferenceControllers(
+// Context context) {
+// ..Add autofill here too..
+// return buildPreferenceControllers(
+// context, null /* parent */, null /* authorities*/);
+// }
+// };
}
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
deleted file mode 100644
index 7abe904..0000000
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * Copyright (C) 2022 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.applications.credentials;
-
-import static androidx.lifecycle.Lifecycle.Event.ON_CREATE;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.app.Dialog;
-import android.app.settings.SettingsEnums;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.pm.PackageManager;
-import android.content.pm.ServiceInfo;
-import android.credentials.CredentialManager;
-import android.credentials.ListEnabledProvidersException;
-import android.credentials.ListEnabledProvidersResponse;
-import android.credentials.SetEnabledProvidersException;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.os.CancellationSignal;
-import android.os.OutcomeReceiver;
-import android.os.UserHandle;
-import android.service.credentials.CredentialProviderInfo;
-import android.util.IconDrawableFactory;
-import android.util.Log;
-
-import androidx.appcompat.app.AlertDialog;
-import androidx.core.content.ContextCompat;
-import androidx.fragment.app.DialogFragment;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.LifecycleOwner;
-import androidx.lifecycle.OnLifecycleEvent;
-import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.SwitchPreference;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.core.BasePreferenceController;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.dashboard.DashboardFragment;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.Executor;
-
-/** Queries available credential manager providers and adds preferences for them. */
-public class CredentialManagerPreferenceController extends BasePreferenceController
- implements LifecycleObserver {
- private static final String TAG = "CredentialManagerPreferenceController";
- private static final int MAX_SELECTABLE_PROVIDERS = 5;
-
- private final PackageManager mPm;
- private final IconDrawableFactory mIconFactory;
- private final List<ServiceInfo> mServices;
- private final Set<String> mEnabledPackageNames;
- private final @Nullable CredentialManager mCredentialManager;
- private final CancellationSignal mCancellationSignal = new CancellationSignal();
- private final Executor mExecutor;
-
- private @Nullable DashboardFragment mParentFragment = null;
-
- public CredentialManagerPreferenceController(Context context, String preferenceKey) {
- super(context, preferenceKey);
- mPm = context.getPackageManager();
- mIconFactory = IconDrawableFactory.newInstance(mContext);
- mServices = new ArrayList<>();
- mEnabledPackageNames = new HashSet<>();
- mExecutor = ContextCompat.getMainExecutor(mContext);
- mCredentialManager =
- getCredentialManager(context, preferenceKey.equals("credentials_test"));
- }
-
- private @Nullable CredentialManager getCredentialManager(Context context, boolean isTest) {
- if (isTest) {
- return null;
- }
-
- Object service = context.getSystemService(Context.CREDENTIAL_SERVICE);
- if (service != null && CredentialManager.isServiceEnabled()) {
- return (CredentialManager) service;
- }
-
- return null;
- }
-
- @VisibleForTesting
- public boolean isConnected() {
- return mCredentialManager != null;
- }
-
- /**
- * Sets the parent fragment and attaches this controller to the settings lifecycle.
- *
- * @param fragment the fragment to use as the parent
- */
- public void setParentFragment(DashboardFragment fragment) {
- mParentFragment = fragment;
- fragment.getSettingsLifecycle().addObserver(this);
- }
-
- @OnLifecycleEvent(ON_CREATE)
- void onCreate(LifecycleOwner lifecycleOwner) {
- if (mCredentialManager == null) {
- return;
- }
-
- mCredentialManager.listEnabledProviders(
- mCancellationSignal,
- mExecutor,
- new OutcomeReceiver<ListEnabledProvidersResponse, ListEnabledProvidersException>() {
- @Override
- public void onResult(ListEnabledProvidersResponse result) {
- Set<String> enabledPackages = new HashSet<>();
- for (String flattenedComponentName : result.getProviderComponentNames()) {
- ComponentName cn =
- ComponentName.unflattenFromString(flattenedComponentName);
- if (cn != null) {
- enabledPackages.add(cn.getPackageName());
- }
- }
-
- List<ServiceInfo> services = new ArrayList<>();
- for (CredentialProviderInfo cpi :
- CredentialProviderInfo.getAvailableServices(mContext, getUser())) {
- services.add(cpi.getServiceInfo());
- }
-
- init(lifecycleOwner, services, enabledPackages);
- }
-
- @Override
- public void onError(ListEnabledProvidersException e) {
- Log.e(TAG, "listEnabledProviders error: " + e.toString());
- }
- });
- }
-
- @VisibleForTesting
- void init(
- LifecycleOwner lifecycleOwner,
- List<ServiceInfo> availableServices,
- Set<String> enabledPackages) {
- mServices.clear();
- mServices.addAll(availableServices);
-
- mEnabledPackageNames.clear();
- mEnabledPackageNames.addAll(enabledPackages);
- }
-
- @Override
- public int getAvailabilityStatus() {
- return mServices.isEmpty() ? CONDITIONALLY_UNAVAILABLE : AVAILABLE;
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
-
- PreferenceGroup group = screen.findPreference(getPreferenceKey());
- Context context = screen.getContext();
-
- for (ServiceInfo serviceInfo : mServices) {
- CharSequence title = "";
- if (serviceInfo.nonLocalizedLabel != null) {
- title = serviceInfo.loadLabel(mPm);
- }
-
- group.addPreference(
- addProviderPreference(
- context,
- title,
- mIconFactory.getBadgedIcon(
- serviceInfo, serviceInfo.applicationInfo, getUser()),
- serviceInfo.packageName));
- }
- }
-
- /**
- * Enables the package name as an enabled credential manager provider.
- *
- * @param packageName the package name to enable
- */
- @VisibleForTesting
- public boolean togglePackageNameEnabled(String packageName) {
- if (mEnabledPackageNames.size() >= MAX_SELECTABLE_PROVIDERS) {
- return false;
- } else {
- mEnabledPackageNames.add(packageName);
- commitEnabledPackages();
- return true;
- }
- }
-
- /**
- * Disables the package name as a credential manager provider.
- *
- * @param packageName the package name to disable
- */
- @VisibleForTesting
- public void togglePackageNameDisabled(String packageName) {
- mEnabledPackageNames.remove(packageName);
- commitEnabledPackages();
- }
-
- /** Returns the enabled credential manager provider package names. */
- @VisibleForTesting
- public Set<String> getEnabledProviders() {
- return mEnabledPackageNames;
- }
-
- /**
- * Returns the enabled credential manager provider flattened component names that can be stored
- * in the setting.
- */
- @VisibleForTesting
- public List<String> getEnabledSettings() {
- // Get all the component names that match the enabled package names.
- List<String> enabledServices = new ArrayList<>();
- for (ServiceInfo service : mServices) {
- if (mEnabledPackageNames.contains(service.packageName)) {
- enabledServices.add(service.getComponentName().flattenToString());
- }
- }
-
- return enabledServices;
- }
-
- private SwitchPreference addProviderPreference(
- @NonNull Context prefContext,
- @NonNull CharSequence title,
- @Nullable Drawable icon,
- @NonNull String packageName) {
- final SwitchPreference pref = new SwitchPreference(prefContext);
- pref.setTitle(title);
- pref.setChecked(mEnabledPackageNames.contains(packageName));
-
- if (icon != null) {
- pref.setIcon(Utils.getSafeIcon(icon));
- }
-
- pref.setOnPreferenceClickListener(
- p -> {
- boolean isChecked = pref.isChecked();
-
- if (isChecked) {
- // Show the error if too many enabled.
- if (!togglePackageNameEnabled(packageName)) {
- final DialogFragment fragment = newErrorDialogFragment();
-
- if (fragment == null || mParentFragment == null) {
- return true;
- }
-
- fragment.show(
- mParentFragment.getActivity().getSupportFragmentManager(),
- ErrorDialogFragment.TAG);
-
- // The user set the check to true so we need to set it back.
- pref.setChecked(false);
- }
-
- return true;
- } else {
- // Show the confirm disable dialog.
- final DialogFragment fragment =
- newConfirmationDialogFragment(packageName, title, pref);
-
- if (fragment == null || mParentFragment == null) {
- return true;
- }
-
- fragment.show(
- mParentFragment.getActivity().getSupportFragmentManager(),
- ConfirmationDialogFragment.TAG);
- }
-
- return true;
- });
-
- return pref;
- }
-
- private void commitEnabledPackages() {
- // Commit using the CredMan API.
- if (mCredentialManager == null) {
- return;
- }
-
- List<String> enabledServices = getEnabledSettings();
- mCredentialManager.setEnabledProviders(
- enabledServices,
- getUser(),
- mExecutor,
- new OutcomeReceiver<Void, SetEnabledProvidersException>() {
- @Override
- public void onResult(Void result) {
- Log.i(TAG, "setEnabledProviders success");
- }
-
- @Override
- public void onError(SetEnabledProvidersException e) {
- Log.e(TAG, "setEnabledProviders error: " + e.toString());
- }
- });
- }
-
- private @Nullable ConfirmationDialogFragment newConfirmationDialogFragment(
- @NonNull String packageName,
- @NonNull CharSequence appName,
- @NonNull SwitchPreference pref) {
- DialogHost host =
- new DialogHost() {
- @Override
- public DashboardFragment getParentFragment() {
- return mParentFragment;
- }
-
- @Override
- public void onDialogClick(int whichButton) {
- if (whichButton == DialogInterface.BUTTON_POSITIVE) {
- // Since the package is now enabled then we
- // should remove it from the enabled list.
- togglePackageNameDisabled(packageName);
- } else if (whichButton == DialogInterface.BUTTON_NEGATIVE) {
- // Set the checked back to true because we
- // backed out of turning this off.
- pref.setChecked(true);
- }
- }
- };
-
- if (host.getParentFragment() == null) {
- return null;
- }
-
- return new ConfirmationDialogFragment(host, packageName, appName);
- }
-
- private @Nullable ErrorDialogFragment newErrorDialogFragment() {
- DialogHost host =
- new DialogHost() {
- @Override
- public DashboardFragment getParentFragment() {
- return mParentFragment;
- }
-
- @Override
- public void onDialogClick(int whichButton) {}
- };
-
- if (host.getParentFragment() == null) {
- return null;
- }
-
- return new ErrorDialogFragment(host);
- }
-
- private int getUser() {
- UserHandle workUser = getWorkProfileUser();
- return workUser != null ? workUser.getIdentifier() : UserHandle.myUserId();
- }
-
- /** Called when the dialog button is clicked. */
- private interface DialogHost {
- void onDialogClick(int whichButton);
-
- DashboardFragment getParentFragment();
- }
-
- /** Dialog fragment parent class. */
- private abstract static class CredentialManagerDialogFragment extends InstrumentedDialogFragment
- implements DialogInterface.OnClickListener {
-
- public static final String TAG = "CredentialManagerDialogFragment";
- public static final String PACKAGE_NAME_KEY = "package_name";
- public static final String APP_NAME_KEY = "app_name";
-
- private DialogHost mDialogHost;
-
- CredentialManagerDialogFragment(DialogHost dialogHost) {
- super();
- setTargetFragment(dialogHost.getParentFragment(), 0);
- mDialogHost = dialogHost;
- }
-
- public DialogHost getDialogHost() {
- return mDialogHost;
- }
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.ACCOUNT;
- }
- }
-
- /** Dialog showing error when too many providers are selected. */
- private static class ErrorDialogFragment extends CredentialManagerDialogFragment {
-
- ErrorDialogFragment(DialogHost dialogHost) {
- super(dialogHost);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- return new AlertDialog.Builder(getActivity())
- .setTitle(getContext().getString(R.string.credman_error_message_title))
- .setMessage(getContext().getString(R.string.credman_error_message))
- .setPositiveButton(android.R.string.ok, this)
- .create();
- }
-
- @Override
- public void onClick(DialogInterface dialog, int which) {}
- }
-
- /**
- * Confirmation dialog fragment shows a dialog to the user to confirm that they are disabling a
- * provider.
- */
- private static class ConfirmationDialogFragment extends CredentialManagerDialogFragment {
-
- ConfirmationDialogFragment(
- DialogHost dialogHost, @NonNull String packageName, @NonNull CharSequence appName) {
- super(dialogHost);
-
- final Bundle argument = new Bundle();
- argument.putString(PACKAGE_NAME_KEY, packageName);
- argument.putCharSequence(APP_NAME_KEY, appName);
- setArguments(argument);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- final Bundle bundle = getArguments();
- final String title =
- getContext()
- .getString(
- R.string.credman_confirmation_message_title,
- bundle.getCharSequence(
- CredentialManagerDialogFragment.APP_NAME_KEY));
-
- return new AlertDialog.Builder(getActivity())
- .setTitle(title)
- .setMessage(getContext().getString(R.string.credman_confirmation_message))
- .setPositiveButton(R.string.credman_confirmation_message_positive_button, this)
- .setNegativeButton(android.R.string.cancel, this)
- .create();
- }
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- getDialogHost().onDialogClick(which);
- }
- }
-}
diff --git a/src/com/android/settings/deviceinfo/aboutphone/DeviceNameWarningDialog.java b/src/com/android/settings/deviceinfo/aboutphone/DeviceNameWarningDialog.java
index b38f13f..b4d2d22 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/DeviceNameWarningDialog.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/DeviceNameWarningDialog.java
@@ -48,7 +48,7 @@
@Override
public int getMetricsCategory() {
- return SettingsEnums.DIALOG_ENABLE_DEVELOPMENT_OPTIONS;
+ return SettingsEnums.DIALOG_DEVICENAME_WARNING;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 8bf5e16..7b44fd3 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -74,8 +74,6 @@
public static final int UID_REMOVED_APPS = -4;
/** Special UID value for data usage by tethering. */
public static final int UID_TETHERING = -5;
- /** Special UID for aggregated other users. */
- public static final long UID_OTHER_USERS = Long.MIN_VALUE;
/** Flag to check if the dock defender mode has been temporarily bypassed */
public static final String SETTINGS_GLOBAL_DOCK_DEFENDER_BYPASS = "dock_defender_bypass";
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntry.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntry.java
index 496200e..893ca4c 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntry.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntry.java
@@ -129,9 +129,6 @@
/** Gets the app label name for this entry. */
public String getAppLabel() {
- if (isOtherUsers()) {
- return mContext.getString(R.string.battery_usage_other_users);
- }
loadLabelAndIcon();
// Returns default applicationn label if we cannot find it.
return mAppLabel == null || mAppLabel.length() == 0
@@ -141,9 +138,6 @@
/** Gets the app icon {@link Drawable} for this entry. */
public Drawable getAppIcon() {
- if (isOtherUsers()) {
- return mContext.getDrawable(R.drawable.ic_power_system);
- }
loadLabelAndIcon();
return mAppIcon != null && mAppIcon.getConstantState() != null
? mAppIcon.getConstantState().newDrawable()
@@ -178,9 +172,6 @@
/** Whether the current BatteryDiffEntry is system component or not. */
public boolean isSystemEntry() {
- if (isOtherUsers()) {
- return true;
- }
switch (mBatteryHistEntry.mConsumerType) {
case ConvertUtils.CONSUMER_TYPE_USER_BATTERY:
case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY:
@@ -200,11 +191,6 @@
return false;
}
- private boolean isOtherUsers() {
- return mBatteryHistEntry.mConsumerType == ConvertUtils.CONSUMER_TYPE_UID_BATTERY
- && mBatteryHistEntry.mUid == BatteryUtils.UID_OTHER_USERS;
- }
-
void loadLabelAndIcon() {
if (mIsLoaded) {
return;
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProvider.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProvider.java
index 4abcdc3..42937e5 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProvider.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProvider.java
@@ -37,6 +37,9 @@
import java.time.Clock;
import java.time.Duration;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
/** {@link ContentProvider} class to fetch battery usage data. */
public class BatteryUsageContentProvider extends ContentProvider {
@@ -100,6 +103,8 @@
switch (sUriMatcher.match(uri)) {
case BATTERY_STATE_CODE:
return getBatteryStates(uri);
+ case APP_USAGE_EVENT_CODE:
+ return getAppUsageEvents(uri);
case APP_USAGE_LATEST_TIMESTAMP_CODE:
return getAppUsageLatestTimestamp(uri);
default:
@@ -153,8 +158,7 @@
}
private Cursor getBatteryStates(Uri uri) {
- final long defaultTimestamp = mClock.millis() - QUERY_DURATION_HOURS.toMillis();
- final long queryTimestamp = getQueryTimestamp(uri, defaultTimestamp);
+ final long queryTimestamp = getQueryTimestamp(uri);
return getBatteryStates(uri, queryTimestamp);
}
@@ -171,6 +175,24 @@
return cursor;
}
+ private Cursor getAppUsageEvents(Uri uri) {
+ final List<Long> queryUserIds = getQueryUserIds(uri);
+ if (queryUserIds == null || queryUserIds.isEmpty()) {
+ return null;
+ }
+ final long queryTimestamp = getQueryTimestamp(uri);
+ final long timestamp = mClock.millis();
+ Cursor cursor = null;
+ try {
+ cursor = mAppUsageEventDao.getAllForUsersAfter(queryUserIds, queryTimestamp);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "query() from:" + uri + " error:" + e);
+ }
+ Log.w(TAG, "query app usage events in " + (mClock.millis() - timestamp) + "/ms");
+ return cursor;
+
+ }
+
private Cursor getAppUsageLatestTimestamp(Uri uri) {
final long queryUserId = getQueryUserId(uri);
if (queryUserId == DatabaseUtils.INVALID_USER_ID) {
@@ -189,6 +211,26 @@
}
// If URI contains query parameter QUERY_KEY_USERID, use the value directly.
+ // Otherwise, return null.
+ private List<Long> getQueryUserIds(Uri uri) {
+ Log.d(TAG, "getQueryUserIds from uri: " + uri);
+ final String value = uri.getQueryParameter(DatabaseUtils.QUERY_KEY_USERID);
+ if (TextUtils.isEmpty(value)) {
+ Log.w(TAG, "empty query value");
+ return null;
+ }
+ try {
+ return Arrays.asList(value.split(","))
+ .stream()
+ .map(s -> Long.parseLong(s.trim()))
+ .collect(Collectors.toList());
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "invalid query value: " + value, e);
+ return null;
+ }
+ }
+
+ // If URI contains query parameter QUERY_KEY_USERID, use the value directly.
// Otherwise, return INVALID_USER_ID.
private long getQueryUserId(Uri uri) {
Log.d(TAG, "getQueryUserId from uri: " + uri);
@@ -198,8 +240,9 @@
// If URI contains query parameter QUERY_KEY_TIMESTAMP, use the value directly.
// Otherwise, load the data for QUERY_DURATION_HOURS by default.
- private long getQueryTimestamp(Uri uri, long defaultTimestamp) {
+ private long getQueryTimestamp(Uri uri) {
Log.d(TAG, "getQueryTimestamp from uri: " + uri);
+ final long defaultTimestamp = mClock.millis() - QUERY_DURATION_HOURS.toMillis();
return getQueryValueFromUri(uri, DatabaseUtils.QUERY_KEY_TIMESTAMP, defaultTimestamp);
}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java b/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
index 38879d9..2e977fd 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
@@ -209,6 +209,25 @@
return appUsageEventBuilder.build();
}
+ /** Converts to {@link AppUsageEvent} from {@link Cursor} */
+ public static AppUsageEvent convertToAppUsageEventFromCursor(final Cursor cursor) {
+ final AppUsageEvent.Builder eventBuilder = AppUsageEvent.newBuilder();
+ eventBuilder.setTimestamp(getLongFromCursor(cursor, AppUsageEventEntity.KEY_TIMESTAMP));
+ eventBuilder.setType(
+ AppUsageEventType.forNumber(
+ getIntegerFromCursor(
+ cursor, AppUsageEventEntity.KEY_APP_USAGE_EVENT_TYPE)));
+ eventBuilder.setPackageName(
+ getStringFromCursor(cursor, AppUsageEventEntity.KEY_PACKAGE_NAME));
+ eventBuilder.setInstanceId(
+ getIntegerFromCursor(cursor, AppUsageEventEntity.KEY_INSTANCE_ID));
+ eventBuilder.setTaskRootPackageName(
+ getStringFromCursor(cursor, AppUsageEventEntity.KEY_TASK_ROOT_PACKAGE_NAME));
+ eventBuilder.setUserId(getLongFromCursor(cursor, AppUsageEventEntity.KEY_USER_ID));
+ eventBuilder.setUid(getLongFromCursor(cursor, AppUsageEventEntity.KEY_UID));
+ return eventBuilder.build();
+ }
+
/** Converts UTC timestamp to human readable local time string. */
public static String utcToLocalTime(Context context, long timestamp) {
final Locale locale = getLocale(context);
@@ -331,4 +350,28 @@
return batteryInformationBuilder.build();
}
+
+ private static int getIntegerFromCursor(final Cursor cursor, final String key) {
+ final int columnIndex = cursor.getColumnIndex(key);
+ if (columnIndex >= 0) {
+ return cursor.getInt(columnIndex);
+ }
+ return 0;
+ }
+
+ private static long getLongFromCursor(final Cursor cursor, final String key) {
+ final int columnIndex = cursor.getColumnIndex(key);
+ if (columnIndex >= 0) {
+ return cursor.getLong(columnIndex);
+ }
+ return 0L;
+ }
+
+ private static String getStringFromCursor(final Cursor cursor, final String key) {
+ final int columnIndex = cursor.getColumnIndex(key);
+ if (columnIndex >= 0) {
+ return cursor.getString(columnIndex);
+ }
+ return "";
+ }
}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DataProcessManager.java b/src/com/android/settings/fuelgauge/batteryusage/DataProcessManager.java
index 350bbce..784f64f 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DataProcessManager.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DataProcessManager.java
@@ -24,10 +24,14 @@
import android.os.UserManager;
import android.util.Log;
+import androidx.annotation.NonNull;
+
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.Utils;
import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -63,9 +67,15 @@
private final DataProcessor.UsageMapAsyncResponse mCallbackFunction;
private Context mContext;
+ private UserManager mUserManager;
private List<BatteryLevelData.PeriodBatteryLevelData> mHourlyBatteryLevelsPerDay;
private Map<Long, Map<String, BatteryHistEntry>> mBatteryHistoryMap;
+ // The start timestamp of battery level data. As we don't know when is the full charge cycle
+ // start time when loading app usage data, this value is used as the start time of querying app
+ // usage data.
+ private long mStartTimestampOfLevelData = 0;
+
private boolean mIsCurrentBatteryHistoryLoaded = false;
private boolean mIsCurrentAppUsageLoaded = false;
private boolean mIsDatabaseAppUsageLoaded = false;
@@ -81,13 +91,15 @@
Context context,
Handler handler,
final DataProcessor.UsageMapAsyncResponse callbackFunction,
- final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay,
- final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
+ @NonNull final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay,
+ @NonNull final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
mContext = context.getApplicationContext();
mHandler = handler;
+ mUserManager = mContext.getSystemService(UserManager.class);
mCallbackFunction = callbackFunction;
mHourlyBatteryLevelsPerDay = hourlyBatteryLevelsPerDay;
mBatteryHistoryMap = batteryHistoryMap;
+ mStartTimestampOfLevelData = getStartTimestampOfBatteryLevelData();
}
/**
@@ -103,6 +115,21 @@
}
@VisibleForTesting
+ long getStartTimestampOfBatteryLevelData() {
+ for (int dailyIndex = 0; dailyIndex < mHourlyBatteryLevelsPerDay.size(); dailyIndex++) {
+ if (mHourlyBatteryLevelsPerDay.get(dailyIndex) == null) {
+ continue;
+ }
+ final List<Long> timestamps =
+ mHourlyBatteryLevelsPerDay.get(dailyIndex).getTimestamps();
+ if (timestamps.size() > 0) {
+ return timestamps.get(0);
+ }
+ }
+ return 0;
+ }
+
+ @VisibleForTesting
List<AppUsageEvent> getAppUsageEventList() {
return mAppUsageEventList;
}
@@ -164,12 +191,17 @@
new AsyncTask<Void, Void, List<AppUsageEvent>>() {
@Override
protected List<AppUsageEvent> doInBackground(Void... voids) {
+ if (!shouldLoadAppUsageData()) {
+ Log.d(TAG, "not loadCurrentAppUsageList");
+ return null;
+ }
final long startTime = System.currentTimeMillis();
// Loads the current battery usage data from the battery stats service.
final int currentUserId = getCurrentUserId();
final int workProfileUserId = getWorkProfileUserId();
final UsageEvents usageEventsForCurrentUser =
- DataProcessor.getAppUsageEventsForUser(mContext, currentUserId);
+ DataProcessor.getAppUsageEventsForUser(
+ mContext, currentUserId, mStartTimestampOfLevelData);
// If fail to load usage events for current user, return null directly and screen-on
// time will not be shown in the UI.
if (usageEventsForCurrentUser == null) {
@@ -180,7 +212,7 @@
if (workProfileUserId != Integer.MIN_VALUE) {
usageEventsForWorkProfile =
DataProcessor.getAppUsageEventsForUser(
- mContext, workProfileUserId);
+ mContext, workProfileUserId, mStartTimestampOfLevelData);
} else {
Log.d(TAG, "there is no work profile");
}
@@ -203,16 +235,8 @@
@Override
protected void onPostExecute(
final List<AppUsageEvent> currentAppUsageList) {
- final int currentUserId = getCurrentUserId();
- final UserManager userManager = mContext.getSystemService(UserManager.class);
- // If current user is locked, don't show screen-on time data in the UI.
- // Even if we have data in the database, we won't show screen-on time because we
- // don't have the latest data.
- if (userManager == null || !userManager.isUserUnlocked(currentUserId)) {
- Log.d(TAG, "current user is locked");
- mShowScreenOnTime = false;
- } else if (currentAppUsageList == null || currentAppUsageList.isEmpty()) {
- Log.d(TAG, "usageEventsForWorkProfile is null or empty");
+ if (currentAppUsageList == null || currentAppUsageList.isEmpty()) {
+ Log.d(TAG, "currentAppUsageList is null or empty");
} else {
mAppUsageEventList.addAll(currentAppUsageList);
}
@@ -223,9 +247,36 @@
}
private void loadDatabaseAppUsageList() {
- // TODO: load app usage data from database.
- mIsDatabaseAppUsageLoaded = true;
- tryToProcessAppUsageData();
+ new AsyncTask<Void, Void, List<AppUsageEvent>>() {
+ @Override
+ protected List<AppUsageEvent> doInBackground(Void... voids) {
+ if (!shouldLoadAppUsageData()) {
+ Log.d(TAG, "not loadDatabaseAppUsageList");
+ return null;
+ }
+ final long startTime = System.currentTimeMillis();
+ // Loads the current battery usage data from the battery stats service.
+ final List<AppUsageEvent> appUsageEventList =
+ DatabaseUtils.getAppUsageEventForUsers(
+ mContext, Calendar.getInstance(), getCurrentUserIds(),
+ mStartTimestampOfLevelData);
+ Log.d(TAG, String.format("execute loadDatabaseAppUsageList size=%d in %d/ms",
+ appUsageEventList.size(), (System.currentTimeMillis() - startTime)));
+ return appUsageEventList;
+ }
+
+ @Override
+ protected void onPostExecute(
+ final List<AppUsageEvent> databaseAppUsageList) {
+ if (databaseAppUsageList == null || databaseAppUsageList.isEmpty()) {
+ Log.d(TAG, "databaseAppUsageList is null or empty");
+ } else {
+ mAppUsageEventList.addAll(databaseAppUsageList);
+ }
+ mIsDatabaseAppUsageLoaded = true;
+ tryToProcessAppUsageData();
+ }
+ }.execute();
}
private void tryToProcessAppUsageData() {
@@ -243,6 +294,8 @@
if (!mShowScreenOnTime) {
return;
}
+ // Sort the appUsageEventList in ascending order based on the timestamp.
+ Collections.sort(mAppUsageEventList, DataProcessor.TIMESTAMP_COMPARATOR);
// TODO: process app usage data to an intermediate result for further use.
}
@@ -262,14 +315,39 @@
// then apply the callback function.
}
+ // Whether we should load app usage data from service or database.
+ private boolean shouldLoadAppUsageData() {
+ if (!mShowScreenOnTime) {
+ return false;
+ }
+ final int currentUserId = getCurrentUserId();
+ // If current user is locked, no need to load app usage data from service or database.
+ if (mUserManager == null || !mUserManager.isUserUnlocked(currentUserId)) {
+ Log.d(TAG, "shouldLoadAppUsageData: false, current user is locked");
+ mShowScreenOnTime = false;
+ return false;
+ }
+ return true;
+ }
+
+ // Returns the list of current user id and work profile id if exists.
+ private List<Integer> getCurrentUserIds() {
+ final List<Integer> userIds = new ArrayList<>();
+ userIds.add(getCurrentUserId());
+ final int workProfileUserId = getWorkProfileUserId();
+ if (workProfileUserId != Integer.MIN_VALUE) {
+ userIds.add(workProfileUserId);
+ }
+ return userIds;
+ }
+
private int getCurrentUserId() {
return mContext.getUserId();
}
private int getWorkProfileUserId() {
final UserHandle userHandle =
- Utils.getManagedProfile(
- mContext.getSystemService(UserManager.class));
+ Utils.getManagedProfile(mUserManager);
return userHandle != null ? userHandle.getIdentifier() : Integer.MIN_VALUE;
}
}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
index bc5c031..bfedeab 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
@@ -100,6 +100,8 @@
public static final String CURRENT_TIME_BATTERY_HISTORY_PLACEHOLDER =
"CURRENT_TIME_BATTERY_HISTORY_PLACEHOLDER";
+ public static final Comparator<AppUsageEvent> TIMESTAMP_COMPARATOR =
+ Comparator.comparing(AppUsageEvent::getTimestamp);
/** A callback listener when battery usage loading async task is executed. */
public interface UsageMapAsyncResponse {
@@ -228,7 +230,8 @@
* Gets the {@link UsageEvents} from system service for the specific user.
*/
@Nullable
- public static UsageEvents getAppUsageEventsForUser(Context context, final int userID) {
+ public static UsageEvents getAppUsageEventsForUser(
+ Context context, final int userID, final long startTimestampOfLevelData) {
final long start = System.currentTimeMillis();
context = DatabaseUtils.getOwnerContext(context);
if (context == null) {
@@ -240,8 +243,9 @@
}
final long sixDaysAgoTimestamp =
DatabaseUtils.getTimestampSixDaysAgo(Calendar.getInstance());
+ final long earliestTimestamp = Math.max(sixDaysAgoTimestamp, startTimestampOfLevelData);
final UsageEvents events = getAppUsageEventsForUser(
- context, userManager, userID, sixDaysAgoTimestamp);
+ context, userManager, userID, earliestTimestamp);
final long elapsedTime = System.currentTimeMillis() - start;
Log.d(TAG, String.format("getAppUsageEventsForUser() for user %d in %d/ms",
userID, elapsedTime));
@@ -585,13 +589,13 @@
userHandle != null ? userHandle.getIdentifier() : Integer.MIN_VALUE;
final List<BatteryDiffEntry> appEntries = new ArrayList<>();
final List<BatteryDiffEntry> systemEntries = new ArrayList<>();
- double consumePowerFromOtherUsers = 0f;
for (BatteryHistEntry entry : batteryHistEntryList) {
final boolean isFromOtherUsers = isConsumedFromOtherUsers(
currentUserId, workProfileUserId, entry);
+ // Not show other users' battery usage data.
if (isFromOtherUsers) {
- consumePowerFromOtherUsers += entry.mConsumePower;
+ continue;
} else {
final BatteryDiffEntry currentBatteryDiffEntry = new BatteryDiffEntry(
context,
@@ -610,9 +614,6 @@
}
}
}
- if (consumePowerFromOtherUsers != 0) {
- systemEntries.add(createOtherUsersEntry(context, consumePowerFromOtherUsers));
- }
// If there is no data, return null instead of empty item.
if (appEntries.isEmpty() && systemEntries.isEmpty()) {
@@ -638,7 +639,7 @@
@Nullable
private static UsageEvents getAppUsageEventsForUser(
Context context, final UserManager userManager, final int userID,
- final long sixDaysAgoTimestamp) {
+ final long earliestTimestamp) {
final String callingPackage = context.getPackageName();
final long now = System.currentTimeMillis();
// When the user is not unlocked, UsageStatsManager will return null, so bypass the
@@ -648,7 +649,7 @@
return null;
}
final long startTime = DatabaseUtils.getAppUsageStartTimestampOfUser(
- context, userID, sixDaysAgoTimestamp);
+ context, userID, earliestTimestamp);
return loadAppUsageEventsForUserFromService(
sUsageStatsManager, startTime, now, userID, callingPackage);
}
@@ -1082,7 +1083,6 @@
allBatteryHistEntryKeys.addAll(nextBatteryHistMap.keySet());
allBatteryHistEntryKeys.addAll(nextTwoBatteryHistMap.keySet());
- double consumePowerFromOtherUsers = 0f;
// Calculates all packages diff usage data in a specific time slot.
for (String key : allBatteryHistEntryKeys) {
final BatteryHistEntry currentEntry =
@@ -1091,6 +1091,20 @@
nextBatteryHistMap.getOrDefault(key, EMPTY_BATTERY_HIST_ENTRY);
final BatteryHistEntry nextTwoEntry =
nextTwoBatteryHistMap.getOrDefault(key, EMPTY_BATTERY_HIST_ENTRY);
+
+ final BatteryHistEntry selectedBatteryEntry =
+ selectBatteryHistEntry(currentEntry, nextEntry, nextTwoEntry);
+ if (selectedBatteryEntry == null) {
+ continue;
+ }
+
+ // Not show other users' battery usage data.
+ final boolean isFromOtherUsers = isConsumedFromOtherUsers(
+ currentUserId, workProfileUserId, selectedBatteryEntry);
+ if (isFromOtherUsers) {
+ continue;
+ }
+
// Cumulative values is a specific time slot for a specific app.
long foregroundUsageTimeInMs =
getDiffValue(
@@ -1133,11 +1147,6 @@
&& consumePower == 0) {
continue;
}
- final BatteryHistEntry selectedBatteryEntry =
- selectBatteryHistEntry(currentEntry, nextEntry, nextTwoEntry);
- if (selectedBatteryEntry == null) {
- continue;
- }
// Forces refine the cumulative value since it may introduce deviation error since we
// will apply the interpolation arithmetic.
final float totalUsageTimeInMs =
@@ -1161,31 +1170,22 @@
cachedUsageConsumePower = cachedUsageConsumePower * ratio;
}
- final boolean isFromOtherUsers = isConsumedFromOtherUsers(
- currentUserId, workProfileUserId, selectedBatteryEntry);
- if (isFromOtherUsers) {
- consumePowerFromOtherUsers += consumePower;
+ final BatteryDiffEntry currentBatteryDiffEntry = new BatteryDiffEntry(
+ context,
+ foregroundUsageTimeInMs,
+ backgroundUsageTimeInMs,
+ consumePower,
+ foregroundUsageConsumePower,
+ foregroundServiceUsageConsumePower,
+ backgroundUsageConsumePower,
+ cachedUsageConsumePower,
+ selectedBatteryEntry);
+ if (currentBatteryDiffEntry.isSystemEntry()) {
+ systemEntries.add(currentBatteryDiffEntry);
} else {
- final BatteryDiffEntry currentBatteryDiffEntry = new BatteryDiffEntry(
- context,
- foregroundUsageTimeInMs,
- backgroundUsageTimeInMs,
- consumePower,
- foregroundUsageConsumePower,
- foregroundServiceUsageConsumePower,
- backgroundUsageConsumePower,
- cachedUsageConsumePower,
- selectedBatteryEntry);
- if (currentBatteryDiffEntry.isSystemEntry()) {
- systemEntries.add(currentBatteryDiffEntry);
- } else {
- appEntries.add(currentBatteryDiffEntry);
- }
+ appEntries.add(currentBatteryDiffEntry);
}
}
- if (consumePowerFromOtherUsers != 0) {
- systemEntries.add(createOtherUsersEntry(context, consumePowerFromOtherUsers));
- }
// If there is no data, return null instead of empty item.
if (appEntries.isEmpty() && systemEntries.isEmpty()) {
@@ -1514,27 +1514,6 @@
return null;
}
- private static BatteryDiffEntry createOtherUsersEntry(
- Context context, final double consumePower) {
- final ContentValues values = new ContentValues();
- values.put(BatteryHistEntry.KEY_UID, BatteryUtils.UID_OTHER_USERS);
- values.put(BatteryHistEntry.KEY_USER_ID, BatteryUtils.UID_OTHER_USERS);
- values.put(BatteryHistEntry.KEY_CONSUMER_TYPE, ConvertUtils.CONSUMER_TYPE_UID_BATTERY);
- // We will show the percentage for the "other users" item only, the aggregated
- // running time information is useless for users to identify individual apps.
- final BatteryDiffEntry batteryDiffEntry = new BatteryDiffEntry(
- context,
- /*foregroundUsageTimeInMs=*/ 0,
- /*backgroundUsageTimeInMs=*/ 0,
- consumePower,
- /*foregroundUsageConsumePower=*/ 0,
- /*foregroundServiceUsageConsumePower=*/ 0,
- /*backgroundUsageConsumePower=*/ 0,
- /*cachedUsageConsumePower=*/ 0,
- new BatteryHistEntry(values));
- return batteryDiffEntry;
- }
-
private static long getCurrentTimeMillis() {
return sFakeCurrentTimeMillis > 0 ? sFakeCurrentTimeMillis : System.currentTimeMillis();
}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java b/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
index f6b4e03..b52938a 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
@@ -46,6 +46,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
+import java.util.stream.Collectors;
/** A utility class to operate battery usage database. */
public final class DatabaseUtils {
@@ -93,6 +94,8 @@
@VisibleForTesting
static Supplier<Cursor> sFakeBatteryStateSupplier;
@VisibleForTesting
+ static Supplier<Cursor> sFakeAppUsageEventSupplier;
+ @VisibleForTesting
static Supplier<Cursor> sFakeAppUsageLatestTimestampSupplier;
private DatabaseUtils() {
@@ -125,6 +128,38 @@
return Math.max(latestTimestamp, earliestTimestamp);
}
+ /** Returns the current user data in app usage event table. */
+ public static List<AppUsageEvent> getAppUsageEventForUsers(
+ Context context,
+ final Calendar calendar,
+ final List<Integer> userIds,
+ final long startTimestampOfLevelData) {
+ final long startTime = System.currentTimeMillis();
+ final long sixDaysAgoTimestamp = getTimestampSixDaysAgo(calendar);
+ final long queryTimestamp = Math.max(startTimestampOfLevelData, sixDaysAgoTimestamp);
+ Log.d(TAG, "sixDayAgoTimestamp: " + sixDaysAgoTimestamp);
+ final String queryUserIdString = userIds.stream()
+ .map(userId -> String.valueOf(userId))
+ .collect(Collectors.joining(","));
+ // Builds the content uri everytime to avoid cache.
+ final Uri appUsageEventUri =
+ new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(AUTHORITY)
+ .appendPath(APP_USAGE_EVENT_TABLE)
+ .appendQueryParameter(
+ QUERY_KEY_TIMESTAMP, Long.toString(queryTimestamp))
+ .appendQueryParameter(QUERY_KEY_USERID, queryUserIdString)
+ .build();
+
+ final List<AppUsageEvent> appUsageEventList =
+ loadAppUsageEventsFromContentProvider(context, appUsageEventUri);
+ Log.d(TAG, String.format("getAppUsageEventForUser userId=%s size=%d in %d/ms",
+ queryUserIdString, appUsageEventList.size(),
+ (System.currentTimeMillis() - startTime)));
+ return appUsageEventList;
+ }
+
/** Long: for timestamp and String: for BatteryHistEntry.getKey() */
public static Map<Long, Map<String, BatteryHistEntry>> getHistoryMapSinceLastFullCharge(
Context context, Calendar calendar) {
@@ -357,6 +392,32 @@
}
}
+ private static List<AppUsageEvent> loadAppUsageEventsFromContentProvider(
+ Context context, Uri appUsageEventUri) {
+ final List<AppUsageEvent> appUsageEventList = new ArrayList<>();
+ context = getOwnerContext(context);
+ if (context == null) {
+ return appUsageEventList;
+ }
+ try (Cursor cursor = sFakeAppUsageEventSupplier != null
+ ? sFakeAppUsageEventSupplier.get()
+ : context.getContentResolver().query(appUsageEventUri, null, null, null)) {
+ if (cursor == null || cursor.getCount() == 0) {
+ return appUsageEventList;
+ }
+ // Loads and recovers all AppUsageEvent data from cursor.
+ while (cursor.moveToNext()) {
+ appUsageEventList.add(ConvertUtils.convertToAppUsageEventFromCursor(cursor));
+ }
+ try {
+ cursor.close();
+ } catch (Exception e) {
+ Log.e(TAG, "cursor.close() failed", e);
+ }
+ }
+ return appUsageEventList;
+ }
+
private static Map<Long, Map<String, BatteryHistEntry>> loadHistoryMapFromContentProvider(
Context context, Uri batteryStateUri) {
context = DatabaseUtils.getOwnerContext(context);
diff --git a/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventDao.java b/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventDao.java
index 578a1ff..19360f4 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventDao.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventDao.java
@@ -41,6 +41,11 @@
@Query("SELECT * FROM AppUsageEventEntity WHERE timestamp > :timestamp ORDER BY timestamp DESC")
List<AppUsageEventEntity> getAllAfter(long timestamp);
+ /** Gets the {@link Cursor} of all recorded data after a specific timestamp of the users. */
+ @Query("SELECT * FROM AppUsageEventEntity WHERE timestamp >= :timestamp"
+ + " AND userId IN (:userIds) ORDER BY timestamp ASC")
+ Cursor getAllForUsersAfter(List<Long> userIds, long timestamp);
+
/** Gets the {@link Cursor} of the latest timestamp of the specific user. */
@Query("SELECT MAX(timestamp) as timestamp FROM AppUsageEventEntity WHERE userId = :userId")
Cursor getLatestTimestampOfUser(long userId);
diff --git a/src/com/android/settings/gestures/TapScreenGestureSettings.java b/src/com/android/settings/gestures/TapScreenGestureSettings.java
index bf847f4..98439d6 100644
--- a/src/com/android/settings/gestures/TapScreenGestureSettings.java
+++ b/src/com/android/settings/gestures/TapScreenGestureSettings.java
@@ -16,11 +16,11 @@
package com.android.settings.gestures;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.SharedPreferences;
import android.hardware.display.AmbientDisplayConfiguration;
-import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
@@ -49,7 +49,7 @@
@Override
public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.SETTINGS_GESTURE_TAP_SCREEN;
+ return SettingsEnums.SETTINGS_GESTURE_TAP_SCREEN;
}
@Override
diff --git a/src/com/android/settings/network/telephony/TelephonyPreferenceDialog.java b/src/com/android/settings/network/telephony/TelephonyPreferenceDialog.java
new file mode 100644
index 0000000..7dbef0c
--- /dev/null
+++ b/src/com/android/settings/network/telephony/TelephonyPreferenceDialog.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network.telephony;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import com.android.settingslib.CustomDialogPreferenceCompat;
+
+/**
+ * This is DialogPreference for supporting connectivity features.
+ */
+public class TelephonyPreferenceDialog extends CustomDialogPreferenceCompat {
+
+ public TelephonyPreferenceDialog(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ public TelephonyPreferenceDialog(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public TelephonyPreferenceDialog(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public TelephonyPreferenceDialog(Context context) {
+ super(context);
+ }
+}
diff --git a/src/com/android/settings/sim/CallsSimListDialogFragment.java b/src/com/android/settings/sim/CallsSimListDialogFragment.java
index 58da111..cbee634 100644
--- a/src/com/android/settings/sim/CallsSimListDialogFragment.java
+++ b/src/com/android/settings/sim/CallsSimListDialogFragment.java
@@ -16,6 +16,8 @@
package com.android.settings.sim;
+import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.telecom.PhoneAccountHandle;
@@ -51,6 +53,12 @@
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
continue;
}
+
+ SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo(subId);
+ if (info == null || (info.isEmbedded()
+ && info.getProfileClass() == PROFILE_CLASS_PROVISIONING)) {
+ continue;
+ }
result.add(subscriptionManager.getActiveSubscriptionInfo(subId));
}
return result;
diff --git a/src/com/android/settings/sim/PreferredSimDialogFragment.java b/src/com/android/settings/sim/PreferredSimDialogFragment.java
index 2bfeafe..50eb993 100644
--- a/src/com/android/settings/sim/PreferredSimDialogFragment.java
+++ b/src/com/android/settings/sim/PreferredSimDialogFragment.java
@@ -16,6 +16,8 @@
package com.android.settings.sim;
+import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING;
+
import android.app.Activity;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
@@ -95,7 +97,8 @@
}
final SubscriptionInfo info = getPreferredSubscription();
- if (info == null) {
+ if (info == null || (info.isEmbedded()
+ && info.getProfileClass() == PROFILE_CLASS_PROVISIONING)) {
dismiss();
return;
}
diff --git a/src/com/android/settings/sim/SelectSpecificDataSimDialogFragment.java b/src/com/android/settings/sim/SelectSpecificDataSimDialogFragment.java
index 9fa60ef..b2ca621 100644
--- a/src/com/android/settings/sim/SelectSpecificDataSimDialogFragment.java
+++ b/src/com/android/settings/sim/SelectSpecificDataSimDialogFragment.java
@@ -16,6 +16,8 @@
package com.android.settings.sim;
+import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING;
+
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.DialogInterface;
@@ -113,6 +115,15 @@
dismiss();
return;
}
+
+ if ((newSubInfo.isEmbedded() && newSubInfo.getProfileClass() == PROFILE_CLASS_PROVISIONING)
+ || (currentDataSubInfo.isEmbedded()
+ && currentDataSubInfo.getProfileClass() == PROFILE_CLASS_PROVISIONING)) {
+ Log.d(TAG, "do not set the provision eSIM");
+ dismiss();
+ return;
+ }
+
Log.d(TAG, "newSubId: " + newSubInfo.getSubscriptionId()
+ "currentDataSubID: " + currentDataSubInfo.getSubscriptionId());
setTargetSubscriptionInfo(newSubInfo);
diff --git a/src/com/android/settings/sim/SimListDialogFragment.java b/src/com/android/settings/sim/SimListDialogFragment.java
index 06b116c..245d31e 100644
--- a/src/com/android/settings/sim/SimListDialogFragment.java
+++ b/src/com/android/settings/sim/SimListDialogFragment.java
@@ -16,6 +16,8 @@
package com.android.settings.sim;
+import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING;
+
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -137,6 +139,11 @@
dismiss();
return;
}
+
+ // Remove the provision eSIM from the subscription list.
+ currentSubscriptions.removeIf(info -> info.isEmbedded()
+ && info.getProfileClass() == PROFILE_CLASS_PROVISIONING);
+
boolean includeAskEveryTime = getArguments().getBoolean(KEY_INCLUDE_ASK_EVERY_TIME);
boolean isCancelItemShowed = getArguments().getBoolean(KEY_SHOW_CANCEL_ITEM);
if (includeAskEveryTime || isCancelItemShowed) {
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntryTest.java
index f8bcbc8..cb2f5c8 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffEntryTest.java
@@ -464,19 +464,6 @@
assertThat(entry.getPackageName()).isEqualTo(expectedPackageName);
}
- @Test
- public void getAppLabel_withOtherUsersUid_returnExpectedLabel() {
- final ContentValues values = getContentValuesWithType(
- ConvertUtils.CONSUMER_TYPE_UID_BATTERY);
- values.put(BatteryHistEntry.KEY_UID, BatteryUtils.UID_OTHER_USERS);
-
- final BatteryDiffEntry batteryDiffEntry = createBatteryDiffEntry(
- /*consumePower=*/ 0, new BatteryHistEntry(values));
-
- assertThat(batteryDiffEntry.getAppLabel())
- .isEqualTo(mContext.getString(R.string.battery_usage_other_users));
- }
-
private BatteryDiffEntry createBatteryDiffEntry(
int consumerType, long uid, boolean isHidden) {
final ContentValues values = getContentValuesWithType(consumerType);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProviderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProviderTest.java
index b43727d..e5547c5 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProviderTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProviderTest.java
@@ -43,13 +43,18 @@
import org.robolectric.Shadows;
import java.time.Duration;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
/** Tests for {@link BatteryUsageContentProvider}. */
@RunWith(RobolectricTestRunner.class)
public final class BatteryUsageContentProviderTest {
private static final Uri VALID_BATTERY_STATE_CONTENT_URI = DatabaseUtils.BATTERY_CONTENT_URI;
+ private static final long TIMESTAMP1 = System.currentTimeMillis();
+ private static final long TIMESTAMP2 = System.currentTimeMillis() + 2;
+ private static final long TIMESTAMP3 = System.currentTimeMillis() + 4;
private static final String PACKAGE_NAME1 = "com.android.settings1";
private static final String PACKAGE_NAME2 = "com.android.settings2";
private static final String PACKAGE_NAME3 = "com.android.settings3";
@@ -181,28 +186,48 @@
}
@Test
+ public void query_appUsageEvent_returnsExpectedResult() {
+ insertAppUsageEvent();
+
+ final List<Long> userIds1 = new ArrayList<>();
+ final long notExistingUserId = 3;
+ userIds1.add(USER_ID1);
+ userIds1.add(USER_ID2);
+ userIds1.add(notExistingUserId);
+ final Cursor cursor1 = getCursorOfAppUsage(userIds1, TIMESTAMP1);
+ assertThat(cursor1.getCount()).isEqualTo(3);
+ // Verifies the queried first battery state.
+ cursor1.moveToFirst();
+ assertThat(cursor1.getString(5 /*packageName*/)).isEqualTo(PACKAGE_NAME1);
+ // Verifies the queried second battery state.
+ cursor1.moveToNext();
+ assertThat(cursor1.getString(5 /*packageName*/)).isEqualTo(PACKAGE_NAME2);
+ // Verifies the queried third battery state.
+ cursor1.moveToNext();
+ assertThat(cursor1.getString(5 /*packageName*/)).isEqualTo(PACKAGE_NAME3);
+
+ final List<Long> userIds2 = new ArrayList<>();
+ userIds2.add(USER_ID1);
+ final Cursor cursor2 = getCursorOfAppUsage(userIds2, TIMESTAMP3);
+ assertThat(cursor2.getCount()).isEqualTo(1);
+ // Verifies the queried first battery state.
+ cursor2.moveToFirst();
+ assertThat(cursor2.getString(5 /*packageName*/)).isEqualTo(PACKAGE_NAME3);
+ }
+
+ @Test
public void query_appUsageTimestamp_returnsExpectedResult() throws Exception {
- mProvider.onCreate();
- final long timestamp1 = System.currentTimeMillis();
- final long timestamp2 = timestamp1 + 2;
- final long timestamp3 = timestamp1 + 4;
- // Inserts some valid testing data.
- BatteryTestUtils.insertDataToAppUsageEventTable(
- mContext, USER_ID1, timestamp1, PACKAGE_NAME1);
- BatteryTestUtils.insertDataToAppUsageEventTable(
- mContext, USER_ID2, timestamp2, PACKAGE_NAME2);
- BatteryTestUtils.insertDataToAppUsageEventTable(
- mContext, USER_ID1, timestamp3, PACKAGE_NAME3);
+ insertAppUsageEvent();
final Cursor cursor1 = getCursorOfLatestTimestamp(USER_ID1);
assertThat(cursor1.getCount()).isEqualTo(1);
cursor1.moveToFirst();
- assertThat(cursor1.getLong(0)).isEqualTo(timestamp3);
+ assertThat(cursor1.getLong(0)).isEqualTo(TIMESTAMP3);
final Cursor cursor2 = getCursorOfLatestTimestamp(USER_ID2);
assertThat(cursor2.getCount()).isEqualTo(1);
cursor2.moveToFirst();
- assertThat(cursor2.getLong(0)).isEqualTo(timestamp2);
+ assertThat(cursor2.getLong(0)).isEqualTo(TIMESTAMP2);
final long notExistingUserId = 3;
final Cursor cursor3 = getCursorOfLatestTimestamp(notExistingUserId);
@@ -383,6 +408,17 @@
return cursor;
}
+ private void insertAppUsageEvent() {
+ mProvider.onCreate();
+ // Inserts some valid testing data.
+ BatteryTestUtils.insertDataToAppUsageEventTable(
+ mContext, USER_ID1, TIMESTAMP1, PACKAGE_NAME1);
+ BatteryTestUtils.insertDataToAppUsageEventTable(
+ mContext, USER_ID2, TIMESTAMP2, PACKAGE_NAME2);
+ BatteryTestUtils.insertDataToAppUsageEventTable(
+ mContext, USER_ID1, TIMESTAMP3, PACKAGE_NAME3);
+ }
+
private Cursor getCursorOfLatestTimestamp(final long userId) {
final Uri appUsageLatestTimestampQueryContentUri =
new Uri.Builder()
@@ -394,10 +430,28 @@
.build();
return mProvider.query(
- appUsageLatestTimestampQueryContentUri,
- /*strings=*/ null,
- /*s=*/ null,
- /*strings1=*/ null,
- /*s1=*/ null);
+ appUsageLatestTimestampQueryContentUri,
+ /*strings=*/ null,
+ /*s=*/ null,
+ /*strings1=*/ null,
+ /*s1=*/ null);
+ }
+
+ private Cursor getCursorOfAppUsage(final List<Long> userIds, final long queryTimestamp) {
+ final String queryUserIdString = userIds.stream()
+ .map(userId -> String.valueOf(userId))
+ .collect(Collectors.joining(","));
+ final Uri appUsageEventUri =
+ new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(DatabaseUtils.AUTHORITY)
+ .appendPath(DatabaseUtils.APP_USAGE_EVENT_TABLE)
+ .appendQueryParameter(
+ DatabaseUtils.QUERY_KEY_TIMESTAMP, Long.toString(queryTimestamp))
+ .appendQueryParameter(DatabaseUtils.QUERY_KEY_USERID, queryUserIdString)
+ .build();
+
+ return mProvider.query(
+ appUsageEventUri, /*strings=*/ null, /*s=*/ null, /*strings1=*/ null, /*s1=*/ null);
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/ConvertUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/ConvertUtilsTest.java
index 42cd7ef..aee8398 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/ConvertUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/ConvertUtilsTest.java
@@ -27,6 +27,7 @@
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.database.MatrixCursor;
import android.os.BatteryManager;
import android.os.BatteryUsageStats;
import android.os.LocaleList;
@@ -336,6 +337,68 @@
}
@Test
+ public void convertToAppUsageEventFromCursor_returnExpectedResult() {
+ final MatrixCursor cursor = new MatrixCursor(
+ new String[]{
+ AppUsageEventEntity.KEY_UID,
+ AppUsageEventEntity.KEY_USER_ID,
+ AppUsageEventEntity.KEY_PACKAGE_NAME,
+ AppUsageEventEntity.KEY_TIMESTAMP,
+ AppUsageEventEntity.KEY_APP_USAGE_EVENT_TYPE,
+ AppUsageEventEntity.KEY_TASK_ROOT_PACKAGE_NAME,
+ AppUsageEventEntity.KEY_INSTANCE_ID});
+ cursor.addRow(
+ new Object[]{
+ 101L,
+ 1001L,
+ "com.android.settings1",
+ 10001L,
+ AppUsageEventType.DEVICE_SHUTDOWN.getNumber(),
+ "com.android.settings2",
+ 100001L});
+ cursor.moveToFirst();
+
+ final AppUsageEvent appUsageEvent = ConvertUtils.convertToAppUsageEventFromCursor(cursor);
+
+ assertThat(appUsageEvent.getUid()).isEqualTo(101L);
+ assertThat(appUsageEvent.getUserId()).isEqualTo(1001L);
+ assertThat(appUsageEvent.getPackageName()).isEqualTo("com.android.settings1");
+ assertThat(appUsageEvent.getTimestamp()).isEqualTo(10001L);
+ assertThat(appUsageEvent.getType()).isEqualTo(AppUsageEventType.DEVICE_SHUTDOWN);
+ assertThat(appUsageEvent.getTaskRootPackageName()).isEqualTo("com.android.settings2");
+ assertThat(appUsageEvent.getInstanceId()).isEqualTo(100001L);
+ }
+
+ @Test
+ public void convertToAppUsageEventFromCursor_emptyInstanceIdAndRootName_returnExpectedResult() {
+ final MatrixCursor cursor = new MatrixCursor(
+ new String[]{
+ AppUsageEventEntity.KEY_UID,
+ AppUsageEventEntity.KEY_USER_ID,
+ AppUsageEventEntity.KEY_PACKAGE_NAME,
+ AppUsageEventEntity.KEY_TIMESTAMP,
+ AppUsageEventEntity.KEY_APP_USAGE_EVENT_TYPE});
+ cursor.addRow(
+ new Object[]{
+ 101L,
+ 1001L,
+ "com.android.settings1",
+ 10001L,
+ AppUsageEventType.DEVICE_SHUTDOWN.getNumber()});
+ cursor.moveToFirst();
+
+ final AppUsageEvent appUsageEvent = ConvertUtils.convertToAppUsageEventFromCursor(cursor);
+
+ assertThat(appUsageEvent.getUid()).isEqualTo(101L);
+ assertThat(appUsageEvent.getUserId()).isEqualTo(1001L);
+ assertThat(appUsageEvent.getPackageName()).isEqualTo("com.android.settings1");
+ assertThat(appUsageEvent.getTimestamp()).isEqualTo(10001L);
+ assertThat(appUsageEvent.getType()).isEqualTo(AppUsageEventType.DEVICE_SHUTDOWN);
+ assertThat(appUsageEvent.getTaskRootPackageName()).isEqualTo("");
+ assertThat(appUsageEvent.getInstanceId()).isEqualTo(0);
+ }
+
+ @Test
public void getLocale_nullContext_returnDefaultLocale() {
assertThat(ConvertUtils.getLocale(/*context=*/ null))
.isEqualTo(Locale.getDefault());
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
index a3578cb..1bfff07 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
@@ -27,10 +27,13 @@
import android.app.usage.IUsageStatsManager;
import android.app.usage.UsageEvents;
import android.content.Context;
+import android.database.MatrixCursor;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.UserManager;
+import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -65,11 +68,31 @@
mDataProcessManager = new DataProcessManager(
mContext, /*handler=*/ null, /*callbackFunction=*/ null,
- /*hourlyBatteryLevelsPerDay=*/ null, /*batteryHistoryMap=*/ null);
+ /*hourlyBatteryLevelsPerDay=*/ new ArrayList<>(), /*batteryHistoryMap=*/ null);
}
@Test
- public void start_loadExpectedCurrentAppUsageData() throws RemoteException {
+ public void start_loadEmptyDatabaseAppUsageData() {
+ final MatrixCursor cursor = new MatrixCursor(
+ new String[]{
+ AppUsageEventEntity.KEY_UID,
+ AppUsageEventEntity.KEY_PACKAGE_NAME,
+ AppUsageEventEntity.KEY_TIMESTAMP});
+ DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
+ doReturn(true).when(mUserManager).isUserUnlocked(anyInt());
+
+ mDataProcessManager.start();
+
+ assertThat(mDataProcessManager.getIsCurrentAppUsageLoaded()).isTrue();
+ assertThat(mDataProcessManager.getIsDatabaseAppUsageLoaded()).isTrue();
+ assertThat(mDataProcessManager.getIsCurrentBatteryHistoryLoaded()).isTrue();
+ assertThat(mDataProcessManager.getShowScreenOnTime()).isTrue();
+ assertThat(mDataProcessManager.getAppUsageEventList()).isEmpty();
+ }
+
+ @Test
+ public void start_loadExpectedAppUsageData() throws RemoteException {
+ // Fake current usage data.
final UsageEvents.Event event1 =
getUsageEvent(UsageEvents.Event.ACTIVITY_RESUMED, /*timestamp=*/ 1);
final UsageEvents.Event event2 =
@@ -82,6 +105,22 @@
.queryEventsForUser(anyLong(), anyLong(), anyInt(), any());
doReturn(true).when(mUserManager).isUserUnlocked(anyInt());
+ // Fake database usage data.
+ final MatrixCursor cursor = new MatrixCursor(
+ new String[]{
+ AppUsageEventEntity.KEY_APP_USAGE_EVENT_TYPE,
+ AppUsageEventEntity.KEY_TIMESTAMP});
+ // Adds fake data into the cursor.
+ cursor.addRow(new Object[] {
+ AppUsageEventType.ACTIVITY_RESUMED.getNumber(), /*timestamp=*/ 3});
+ cursor.addRow(new Object[] {
+ AppUsageEventType.ACTIVITY_RESUMED.getNumber(), /*timestamp=*/ 4});
+ cursor.addRow(new Object[] {
+ AppUsageEventType.ACTIVITY_STOPPED.getNumber(), /*timestamp=*/ 5});
+ cursor.addRow(new Object[] {
+ AppUsageEventType.ACTIVITY_STOPPED.getNumber(), /*timestamp=*/ 6});
+ DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
+
mDataProcessManager.start();
assertThat(mDataProcessManager.getIsCurrentAppUsageLoaded()).isTrue();
@@ -89,11 +128,19 @@
assertThat(mDataProcessManager.getIsCurrentBatteryHistoryLoaded()).isTrue();
assertThat(mDataProcessManager.getShowScreenOnTime()).isTrue();
final List<AppUsageEvent> appUsageEventList = mDataProcessManager.getAppUsageEventList();
- assertThat(appUsageEventList.size()).isEqualTo(2);
+ assertThat(appUsageEventList.size()).isEqualTo(6);
assertAppUsageEvent(
appUsageEventList.get(0), AppUsageEventType.ACTIVITY_RESUMED, /*timestamp=*/ 1);
assertAppUsageEvent(
appUsageEventList.get(1), AppUsageEventType.ACTIVITY_STOPPED, /*timestamp=*/ 2);
+ assertAppUsageEvent(
+ appUsageEventList.get(2), AppUsageEventType.ACTIVITY_RESUMED, /*timestamp=*/ 3);
+ assertAppUsageEvent(
+ appUsageEventList.get(3), AppUsageEventType.ACTIVITY_RESUMED, /*timestamp=*/ 4);
+ assertAppUsageEvent(
+ appUsageEventList.get(4), AppUsageEventType.ACTIVITY_STOPPED, /*timestamp=*/ 5);
+ assertAppUsageEvent(
+ appUsageEventList.get(5), AppUsageEventType.ACTIVITY_STOPPED, /*timestamp=*/ 6);
}
@Test
@@ -106,6 +153,14 @@
.when(mUsageStatsManager)
.queryEventsForUser(anyLong(), anyLong(), anyInt(), any());
doReturn(false).when(mUserManager).isUserUnlocked(anyInt());
+ final MatrixCursor cursor = new MatrixCursor(
+ new String[]{
+ AppUsageEventEntity.KEY_UID,
+ AppUsageEventEntity.KEY_PACKAGE_NAME,
+ AppUsageEventEntity.KEY_TIMESTAMP});
+ // Adds fake data into the cursor.
+ cursor.addRow(new Object[] {101L, "app name1", 1001L});
+ DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
mDataProcessManager.start();
@@ -113,6 +168,42 @@
assertThat(mDataProcessManager.getShowScreenOnTime()).isFalse();
}
+ @Test
+ public void getStartTimestampOfBatteryLevelData_returnExpectedResult() {
+ final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
+ new ArrayList<>();
+ final List<Long> timestamps = new ArrayList<>();
+ timestamps.add(101L);
+ timestamps.add(1001L);
+ final List<Integer> levels = new ArrayList<>();
+ levels.add(1);
+ levels.add(2);
+ hourlyBatteryLevelsPerDay.add(null);
+ hourlyBatteryLevelsPerDay.add(
+ new BatteryLevelData.PeriodBatteryLevelData(timestamps, levels));
+
+ final DataProcessManager dataProcessManager = new DataProcessManager(
+ mContext, /*handler=*/ null, /*callbackFunction=*/ null,
+ hourlyBatteryLevelsPerDay, /*batteryHistoryMap=*/ null);
+
+ assertThat(dataProcessManager.getStartTimestampOfBatteryLevelData()).isEqualTo(101);
+ }
+
+ @Test
+ public void getStartTimestampOfBatteryLevelData_emptyLevels_returnZero() {
+ final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
+ new ArrayList<>();
+ hourlyBatteryLevelsPerDay.add(null);
+ hourlyBatteryLevelsPerDay.add(
+ new BatteryLevelData.PeriodBatteryLevelData(new ArrayList<>(), new ArrayList<>()));
+
+ final DataProcessManager dataProcessManager = new DataProcessManager(
+ mContext, /*handler=*/ null, /*callbackFunction=*/ null,
+ hourlyBatteryLevelsPerDay, /*batteryHistoryMap=*/ null);
+
+ assertThat(dataProcessManager.getStartTimestampOfBatteryLevelData()).isEqualTo(0);
+ }
+
private UsageEvents getUsageEvents(final List<UsageEvents.Event> events) {
UsageEvents usageEvents = new UsageEvents(events, new String[] {"package"});
Parcel parcel = Parcel.obtain();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java
index f0412df..0f95754 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java
@@ -41,7 +41,6 @@
import android.os.UserManager;
import android.text.format.DateUtils;
-import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -213,7 +212,7 @@
.when(mUsageStatsManager)
.queryEventsForUser(anyLong(), anyLong(), anyInt(), any());
- assertThat(DataProcessor.getAppUsageEventsForUser(mContext, userId))
+ assertThat(DataProcessor.getAppUsageEventsForUser(mContext, userId, 0))
.isEqualTo(mUsageEvents1);
}
@@ -223,7 +222,7 @@
// Test locked user.
doReturn(false).when(mUserManager).isUserUnlocked(userId);
- assertThat(DataProcessor.getAppUsageEventsForUser(mContext, userId)).isNull();
+ assertThat(DataProcessor.getAppUsageEventsForUser(mContext, userId, 0)).isNull();
}
@Test
@@ -233,7 +232,7 @@
doReturn(null)
.when(mUsageStatsManager).queryEventsForUser(anyLong(), anyLong(), anyInt(), any());
- assertThat(DataProcessor.getAppUsageEventsForUser(mContext, userId)).isNull();
+ assertThat(DataProcessor.getAppUsageEventsForUser(mContext, userId, 0)).isNull();
}
@Test public void generateAppUsageEventListFromUsageEvents_returnExpectedResult() {
@@ -647,6 +646,7 @@
public void getBatteryUsageMap_emptyHistoryMap_returnNull() {
final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
new ArrayList<>();
+
hourlyBatteryLevelsPerDay.add(
new BatteryLevelData.PeriodBatteryLevelData(new ArrayList<>(), new ArrayList<>()));
@@ -933,13 +933,7 @@
/*foregroundUsageConsumePower=*/ 5, /*foregroundServiceUsageConsumePower=*/ 5,
/*backgroundUsageConsumePower=*/ 5, /*cachedUsageConsumePower=*/ 5,
/*foregroundUsageTimeInMs=*/ 10, /*backgroundUsageTimeInMs=*/ 10);
- assertBatteryDiffEntry(
- resultDiffData.getSystemDiffEntryList().get(0), BatteryUtils.UID_OTHER_USERS,
- /*uid=*/ BatteryUtils.UID_OTHER_USERS, ConvertUtils.CONSUMER_TYPE_UID_BATTERY,
- /*consumePercentage=*/ 100.0,
- /*foregroundUsageConsumePower=*/ 0, /*foregroundServiceUsageConsumePower=*/ 0,
- /*backgroundUsageConsumePower=*/ 0, /*cachedUsageConsumePower=*/ 0,
- /*foregroundUsageTimeInMs=*/ 0, /*backgroundUsageTimeInMs=*/ 0);
+ assertThat(resultDiffData.getSystemDiffEntryList()).isEmpty();
assertThat(resultMap.get(0).get(0)).isNotNull();
assertThat(resultMap.get(0).get(DataProcessor.SELECTED_INDEX_ALL)).isNotNull();
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
index a04baa0..7d04e85 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
@@ -277,6 +277,62 @@
}
@Test
+ public void getAppUsageEventForUsers_emptyCursorContent_returnEmptyMap() {
+ final MatrixCursor cursor = new MatrixCursor(
+ new String[]{
+ AppUsageEventEntity.KEY_UID,
+ AppUsageEventEntity.KEY_USER_ID,
+ AppUsageEventEntity.KEY_PACKAGE_NAME,
+ AppUsageEventEntity.KEY_TIMESTAMP,
+ AppUsageEventEntity.KEY_APP_USAGE_EVENT_TYPE});
+ DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
+
+ assertThat(DatabaseUtils.getAppUsageEventForUsers(
+ mContext,
+ /*calendar=*/ null,
+ /*userIds=*/ new ArrayList<>(),
+ /*startTimestampOfLevelData=*/ 0)).isEmpty();
+ }
+
+ @Test
+ public void getAppUsageEventForUsers_nullCursor_returnEmptyMap() {
+ DatabaseUtils.sFakeAppUsageEventSupplier = () -> null;
+ assertThat(DatabaseUtils.getAppUsageEventForUsers(
+ mContext,
+ /*calendar=*/ null,
+ /*userIds=*/ new ArrayList<>(),
+ /*startTimestampOfLevelData=*/ 0)).isEmpty();
+ }
+
+ @Test
+ public void getAppUsageEventForUsers_returnExpectedMap() {
+ final Long timestamp1 = 1001L;
+ final Long timestamp2 = 1002L;
+ final MatrixCursor cursor = new MatrixCursor(
+ new String[]{
+ AppUsageEventEntity.KEY_UID,
+ AppUsageEventEntity.KEY_PACKAGE_NAME,
+ AppUsageEventEntity.KEY_TIMESTAMP});
+ // Adds fake data into the cursor.
+ cursor.addRow(new Object[] {101L, "app name1", timestamp1});
+ cursor.addRow(new Object[] {101L, "app name2", timestamp2});
+ cursor.addRow(new Object[] {101L, "app name3", timestamp2});
+ cursor.addRow(new Object[] {101L, "app name4", timestamp2});
+ DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
+
+ final List<AppUsageEvent> appUsageEventList = DatabaseUtils.getAppUsageEventForUsers(
+ mContext,
+ /*calendar=*/ null,
+ /*userIds=*/ new ArrayList<>(),
+ /*startTimestampOfLevelData=*/ 0);
+
+ assertThat(appUsageEventList.get(0).getPackageName()).isEqualTo("app name1");
+ assertThat(appUsageEventList.get(1).getPackageName()).isEqualTo("app name2");
+ assertThat(appUsageEventList.get(2).getPackageName()).isEqualTo("app name3");
+ assertThat(appUsageEventList.get(3).getPackageName()).isEqualTo("app name4");
+ }
+
+ @Test
public void getHistoryMapSinceLastFullCharge_emptyCursorContent_returnEmptyMap() {
final MatrixCursor cursor = new MatrixCursor(
new String[] {
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventDaoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventDaoTest.java
index ade585f..4883d4f 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventDaoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventDaoTest.java
@@ -31,11 +31,13 @@
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
+import java.util.ArrayList;
import java.util.List;
/** Tests for {@link AppUsageEventDao}. */
@RunWith(RobolectricTestRunner.class)
public final class AppUsageEventDaoTest {
+ private static final int CURSOR_COLUMN_SIZE = 8;
private static final long TIMESTAMP1 = System.currentTimeMillis();
private static final long TIMESTAMP2 = System.currentTimeMillis() + 2;
private static final long TIMESTAMP3 = System.currentTimeMillis() + 4;
@@ -78,6 +80,36 @@
}
@Test
+ public void appUsageEventDao_getAllForUsersAfter() {
+ final List<Long> userIds1 = new ArrayList<>();
+ final long notExistingUserId = 3;
+ userIds1.add(USER_ID1);
+ userIds1.add(USER_ID2);
+ userIds1.add(notExistingUserId);
+ final Cursor cursor1 = mAppUsageEventDao.getAllForUsersAfter(userIds1, TIMESTAMP1);
+ assertThat(cursor1.getCount()).isEqualTo(3);
+ assertThat(cursor1.getColumnCount()).isEqualTo(CURSOR_COLUMN_SIZE);
+ // Verifies the queried first battery state.
+ cursor1.moveToFirst();
+ assertThat(cursor1.getString(5 /*packageName*/)).isEqualTo(PACKAGE_NAME1);
+ // Verifies the queried second battery state.
+ cursor1.moveToNext();
+ assertThat(cursor1.getString(5 /*packageName*/)).isEqualTo(PACKAGE_NAME2);
+ // Verifies the queried third battery state.
+ cursor1.moveToNext();
+ assertThat(cursor1.getString(5 /*packageName*/)).isEqualTo(PACKAGE_NAME3);
+
+ final List<Long> userIds2 = new ArrayList<>();
+ userIds2.add(USER_ID1);
+ final Cursor cursor2 = mAppUsageEventDao.getAllForUsersAfter(userIds2, TIMESTAMP3);
+ assertThat(cursor2.getCount()).isEqualTo(1);
+ assertThat(cursor2.getColumnCount()).isEqualTo(CURSOR_COLUMN_SIZE);
+ // Verifies the queried first battery state.
+ cursor2.moveToFirst();
+ assertThat(cursor2.getString(5 /*packageName*/)).isEqualTo(PACKAGE_NAME3);
+ }
+
+ @Test
public void appUsageEventDao_getLatestTimestampOfUser() throws Exception {
final Cursor cursor1 = mAppUsageEventDao.getLatestTimestampOfUser(USER_ID1);
assertThat(cursor1.getCount()).isEqualTo(1);
diff --git a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
deleted file mode 100644
index 5848326..0000000
--- a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2022 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.applications.credentials;
-
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.ServiceInfo;
-import android.os.Looper;
-
-import androidx.lifecycle.Lifecycle;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import com.google.android.collect.Lists;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-@RunWith(AndroidJUnit4.class)
-public class CredentialManagerPreferenceControllerTest {
-
- private Context mContext;
- private PreferenceScreen mScreen;
- private PreferenceCategory mCredentialsPreferenceCategory;
-
- @Before
- public void setUp() {
- mContext = spy(ApplicationProvider.getApplicationContext());
- if (Looper.myLooper() == null) {
- Looper.prepare(); // needed to create the preference screen
- }
- mScreen = new PreferenceManager(mContext).createPreferenceScreen(mContext);
- mCredentialsPreferenceCategory = new PreferenceCategory(mContext);
- mCredentialsPreferenceCategory.setKey("credentials_test");
- mScreen.addPreference(mCredentialsPreferenceCategory);
- }
-
- @Test
- // Tests that getAvailabilityStatus() does not throw an exception if it's called before the
- // Controller is initialized (this can happen during indexing).
- public void getAvailabilityStatus_withoutInit_returnsUnavailable() {
- CredentialManagerPreferenceController controller =
- new CredentialManagerPreferenceController(
- mContext, mCredentialsPreferenceCategory.getKey());
- assertThat(controller.isConnected()).isFalse();
- assertThat(controller.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_noServices_returnsUnavailable() {
- CredentialManagerPreferenceController controller =
- createControllerWithServices(Collections.emptyList());
- assertThat(controller.isConnected()).isFalse();
- assertThat(controller.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_withServices_returnsAvailable() {
- CredentialManagerPreferenceController controller =
- createControllerWithServices(Lists.newArrayList(createServiceInfo()));
- assertThat(controller.isConnected()).isFalse();
- assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void displayPreference_noServices_noPreferencesAdded() {
- CredentialManagerPreferenceController controller =
- createControllerWithServices(Collections.emptyList());
- controller.displayPreference(mScreen);
- assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(0);
- }
-
- @Test
- public void displayPreference_withServices_preferencesAdded() {
- CredentialManagerPreferenceController controller =
- createControllerWithServices(Lists.newArrayList(createServiceInfo()));
- controller.displayPreference(mScreen);
- assertThat(controller.isConnected()).isFalse();
- assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
- }
-
- @Test
- public void getAvailabilityStatus_handlesToggleAndSave() {
- CredentialManagerPreferenceController controller =
- createControllerWithServices(
- Lists.newArrayList(
- createServiceInfo("com.android.provider1", "ClassA"),
- createServiceInfo("com.android.provider1", "ClassB"),
- createServiceInfo("com.android.provider2", "ClassA"),
- createServiceInfo("com.android.provider3", "ClassA"),
- createServiceInfo("com.android.provider4", "ClassA"),
- createServiceInfo("com.android.provider5", "ClassA"),
- createServiceInfo("com.android.provider6", "ClassA")));
- assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- assertThat(controller.isConnected()).isFalse();
-
- // Ensure that we stay under 5 providers.
- assertThat(controller.togglePackageNameEnabled("com.android.provider1")).isTrue();
- assertThat(controller.togglePackageNameEnabled("com.android.provider2")).isTrue();
- assertThat(controller.togglePackageNameEnabled("com.android.provider3")).isTrue();
- assertThat(controller.togglePackageNameEnabled("com.android.provider4")).isTrue();
- assertThat(controller.togglePackageNameEnabled("com.android.provider5")).isTrue();
- assertThat(controller.togglePackageNameEnabled("com.android.provider6")).isFalse();
-
- // Check that they are all actually registered.
- Set<String> enabledProviders = controller.getEnabledProviders();
- assertThat(enabledProviders.size()).isEqualTo(5);
- assertThat(enabledProviders.contains("com.android.provider1")).isTrue();
- assertThat(enabledProviders.contains("com.android.provider2")).isTrue();
- assertThat(enabledProviders.contains("com.android.provider3")).isTrue();
- assertThat(enabledProviders.contains("com.android.provider4")).isTrue();
- assertThat(enabledProviders.contains("com.android.provider5")).isTrue();
- assertThat(enabledProviders.contains("com.android.provider6")).isFalse();
-
- // Check that the settings string has the right component names.
- List<String> enabledServices = controller.getEnabledSettings();
- assertThat(enabledServices.size()).isEqualTo(6);
- assertThat(enabledServices.contains("com.android.provider1/ClassA")).isTrue();
- assertThat(enabledServices.contains("com.android.provider1/ClassB")).isTrue();
- assertThat(enabledServices.contains("com.android.provider2/ClassA")).isTrue();
- assertThat(enabledServices.contains("com.android.provider3/ClassA")).isTrue();
- assertThat(enabledServices.contains("com.android.provider4/ClassA")).isTrue();
- assertThat(enabledServices.contains("com.android.provider5/ClassA")).isTrue();
- assertThat(enabledServices.contains("com.android.provider6/ClassA")).isFalse();
-
- // Toggle the provider disabled.
- controller.togglePackageNameDisabled("com.android.provider2");
-
- // Check that the provider was removed from the list of providers.
- Set<String> currentlyEnabledProviders = controller.getEnabledProviders();
- assertThat(currentlyEnabledProviders.size()).isEqualTo(4);
- assertThat(currentlyEnabledProviders.contains("com.android.provider1")).isTrue();
- assertThat(currentlyEnabledProviders.contains("com.android.provider2")).isFalse();
- assertThat(currentlyEnabledProviders.contains("com.android.provider3")).isTrue();
- assertThat(currentlyEnabledProviders.contains("com.android.provider4")).isTrue();
- assertThat(currentlyEnabledProviders.contains("com.android.provider5")).isTrue();
- assertThat(currentlyEnabledProviders.contains("com.android.provider6")).isFalse();
-
- // Check that the provider was removed from the list of services stored in the setting.
- List<String> currentlyEnabledServices = controller.getEnabledSettings();
- assertThat(currentlyEnabledServices.size()).isEqualTo(5);
- assertThat(currentlyEnabledServices.contains("com.android.provider1/ClassA")).isTrue();
- assertThat(currentlyEnabledServices.contains("com.android.provider1/ClassB")).isTrue();
- assertThat(currentlyEnabledServices.contains("com.android.provider3/ClassA")).isTrue();
- assertThat(currentlyEnabledServices.contains("com.android.provider4/ClassA")).isTrue();
- assertThat(currentlyEnabledServices.contains("com.android.provider5/ClassA")).isTrue();
- assertThat(currentlyEnabledServices.contains("com.android.provider6/ClassA")).isFalse();
- }
-
- private CredentialManagerPreferenceController createControllerWithServices(
- List<ServiceInfo> availableServices) {
- CredentialManagerPreferenceController controller =
- new CredentialManagerPreferenceController(
- mContext, mCredentialsPreferenceCategory.getKey());
- controller.init(() -> mock(Lifecycle.class), availableServices, new HashSet<>());
- return controller;
- }
-
- private ServiceInfo createServiceInfo() {
- return createServiceInfo("com.android.provider", "CredManProvider");
- }
-
- private ServiceInfo createServiceInfo(String packageName, String className) {
- ServiceInfo si = new ServiceInfo();
- si.packageName = packageName;
- si.name = className;
- si.nonLocalizedLabel = "test";
-
- si.applicationInfo = new ApplicationInfo();
- si.applicationInfo.packageName = packageName;
- si.applicationInfo.nonLocalizedLabel = "test";
-
- return si;
- }
-}
diff --git a/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
index 5f02b04..bff9d41 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
@@ -41,6 +41,7 @@
import com.android.settings.testutils.ResourcesUtils;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -102,6 +103,7 @@
}
@Test
+ @Ignore
public void getAvailabilityStatus_isNotVoiceCapable_shouldBeUNSUPPORTED_ON_DEVICE() {
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
@@ -121,6 +123,7 @@
}
@Test
+ @Ignore
public void updateState_singleSim_shouldUpdateTitleAndPhoneNumber() {
final String phoneNumber = "1111111111";
doReturn(phoneNumber).when(mController).getFormattedPhoneNumber(mSubscriptionInfo);
@@ -134,6 +137,7 @@
}
@Test
+ @Ignore
public void updateState_multiSim_shouldUpdateTitleAndPhoneNumberOfMultiplePreferences() {
final String phoneNumber = "1111111111";
doReturn(phoneNumber).when(mController).getFormattedPhoneNumber(mSubscriptionInfo);
@@ -151,6 +155,7 @@
}
@Test
+ @Ignore
public void getSummary_cannotGetActiveSubscriptionInfo_shouldShowUnknown() {
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(null);
@@ -162,6 +167,7 @@
}
@Test
+ @Ignore
public void getSummary_getEmptySubscriptionInfo_shouldShowUnknown() {
List<SubscriptionInfo> infos = new ArrayList<>();
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(infos);
diff --git a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
index 8beeffb..cd9d2a3 100644
--- a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
@@ -56,6 +56,7 @@
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -177,6 +178,7 @@
any(Handler.class));
}
+ @Ignore
@Test
@UiThreadTest
public void onPause_shouldUnregisterCallback() {
diff --git a/tests/unit/src/com/android/settings/network/InternetResetHelperTest.java b/tests/unit/src/com/android/settings/network/InternetResetHelperTest.java
index 3fe6882..a527822 100644
--- a/tests/unit/src/com/android/settings/network/InternetResetHelperTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetResetHelperTest.java
@@ -42,6 +42,7 @@
import com.android.settingslib.utils.HandlerInjector;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -241,6 +242,7 @@
verify(mRecoveryWorker).triggerRestart();
}
+ @Ignore
@Test
public void checkRecovering_isRecovering_showResetting() {
when(mRecoveryWorker.isRecovering()).thenReturn(true);
@@ -250,6 +252,7 @@
verify(mResettingPreference).setVisible(true);
}
+ @Ignore
@Test
public void checkRecovering_isNotRecovering_doNotShowResetting() {
when(mRecoveryWorker.isRecovering()).thenReturn(false);
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
index 345631c..553fefd 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
@@ -66,6 +66,7 @@
import com.android.wifitrackerlib.WifiPickerTracker;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -462,6 +463,7 @@
}
}
+ @Ignore
@Test
@UiThreadTest
public void onNotifyChange_FirstTimeDisableToggleState_showDialog() {
diff --git a/tests/unit/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/unit/src/com/android/settings/network/SubscriptionUtilTest.java
index 63dca7e..e06e0a5 100644
--- a/tests/unit/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/unit/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -459,6 +459,7 @@
}
@Test
+ @Ignore
public void isSimHardwareVisible_configAsVisible_returnTrue() {
when(mContext.getResources()).thenReturn(mResources);
when(mResources.getBoolean(R.bool.config_show_sim_info))
diff --git a/tests/unit/src/com/android/settings/wifi/RequestToggleWiFiActivityTest.java b/tests/unit/src/com/android/settings/wifi/RequestToggleWiFiActivityTest.java
index 0e3dd40..8810386 100644
--- a/tests/unit/src/com/android/settings/wifi/RequestToggleWiFiActivityTest.java
+++ b/tests/unit/src/com/android/settings/wifi/RequestToggleWiFiActivityTest.java
@@ -34,6 +34,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -76,6 +77,7 @@
}
@Test
+ @Ignore
public void getAppLabel_nullPackageName_returnNull() {
fakeCallingPackage(null);
@@ -83,6 +85,7 @@
}
@Test
+ @Ignore
public void getAppLabel_settingsPackageName_returnNotNull() {
fakeCallingPackage("com.android.settings");