Snap for 5515452 from 15524dbaee to qt-release
Change-Id: I4c8397d8fd3a15354fc69c08e8cb259028124fc5
This commit is contained in:
@@ -436,6 +436,17 @@
|
||||
android:value="com.android.settings.biometrics.face.FaceSettings" />
|
||||
</activity>
|
||||
|
||||
<activity android:name="Settings$FingerprintSettingsActivity"
|
||||
android:label="@string/security_settings_fingerprint_preference_title"
|
||||
android:icon="@drawable/ic_fingerprint_header">
|
||||
<intent-filter>
|
||||
<action android:name="android.settings.FINGERPRINT_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.biometrics.fingerprint.FingerprintSettings$FingerprintSettingsFragment" />
|
||||
</activity>
|
||||
|
||||
<activity android:name=".bluetooth.DevicePickerActivity"
|
||||
android:label="@string/device_picker"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
|
||||
0
res/drawable-nodpi/accessibility_timeout
Normal file
0
res/drawable-nodpi/accessibility_timeout
Normal file
@@ -26,8 +26,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/filter_settings"
|
||||
|
||||
0
res/raw/accessibility_timeout.mp4
Normal file
0
res/raw/accessibility_timeout.mp4
Normal file
@@ -7587,7 +7587,7 @@
|
||||
<!-- Do not disturb: what to block option [CHAR LIMIT=NONE] -->
|
||||
<string name="zen_mode_block_effect_ambient">Don\'t wake for notifications</string>
|
||||
<!-- Do not disturb: what to block option [CHAR LIMIT=NONE] -->
|
||||
<string name="zen_mode_block_effect_list">Hide from notification list</string>
|
||||
<string name="zen_mode_block_effect_list">Hide from pull-down shade</string>
|
||||
|
||||
<!-- Do not disturb: what to block summary, none -->
|
||||
<string name="zen_mode_block_effect_summary_none">Never</string>
|
||||
@@ -8382,13 +8382,13 @@
|
||||
</plurals>
|
||||
|
||||
<!-- [CHAR LIMIT=40] Zen mode settings: Messages option -->
|
||||
<string name="zen_mode_messages">Allow text messages</string>
|
||||
<string name="zen_mode_messages">Allow messages</string>
|
||||
|
||||
<!-- Do not disturb settings, messages, events and reminders footer [CHAR LIMIT=NONE]-->
|
||||
<string name="zen_mode_messages_footer">To be sure allowed messages make sound, check whether your device is set to ring, vibrate, or silent.</string>
|
||||
|
||||
<!-- [CHAR LIMIT=NONE] Zen mode custom rule settings: Messages screen footer -->
|
||||
<string name="zen_mode_custom_messages_footer">For \u2018<xliff:g id="schedule_name" example="Schedule 1">%1$s</xliff:g>\u2019 incoming text messages are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
|
||||
<string name="zen_mode_custom_messages_footer">For \u2018<xliff:g id="schedule_name" example="Schedule 1">%1$s</xliff:g>\u2019 incoming messages are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
|
||||
|
||||
<!-- [CHAR LIMIT=40] Zen mode settings: Allow messages to bypass DND title -->
|
||||
<string name="zen_mode_messages_title">SMS, MMS, and messaging apps</string>
|
||||
|
||||
@@ -211,4 +211,25 @@
|
||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
|
||||
</style>
|
||||
|
||||
<!-- This light theme for a window that can be applied to show light theme in setupwizard flow,
|
||||
regardless of whether system theme changed to dark or light theme. WARNING: your settings
|
||||
activity shows in setupwizard flow, but doesn't use setupwizard theme. This theme must be
|
||||
set to ensure settings activity always shows light theme in setupwizard flow. -->
|
||||
<style name="LightTheme.SettingsBase.SetupWizard" parent="@android:style/Theme.DeviceDefault">
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
<item name="android:navigationBarColor">@android:color/white</item>
|
||||
<item name="android:windowLightNavigationBar">true</item>
|
||||
<item name="android:navigationBarDividerColor">@*android:color/navigation_bar_divider_device_default_settings</item>
|
||||
|
||||
<item name="android:colorPrimary">@*android:color/primary_device_default_settings_light</item>
|
||||
<item name="android:colorPrimaryDark">@*android:color/primary_dark_device_default_settings_light</item>
|
||||
<item name="android:colorBackground">@*android:color/background_device_default_light</item>
|
||||
<item name="android:colorAccent">@*android:color/accent_device_default_light</item>
|
||||
|
||||
<item name="android:listDivider">@*android:color/list_divider_color_light</item>
|
||||
|
||||
<item name="android:textColorPrimary">@*android:color/primary_text_light</item>
|
||||
<item name="android:textColorSecondary">@*android:color/secondary_text_light</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
<com.android.settings.widget.VideoPreference
|
||||
android:key="accessibility_content_timeout_video"
|
||||
android:title="@string/summary_placeholder"
|
||||
settings:animation="@raw/gesture_swipe_up"
|
||||
settings:preview="@drawable/gesture_swipe_up"
|
||||
settings:animation="@raw/accessibility_timeout"
|
||||
settings:preview="@drawable/accessibility_timeout"
|
||||
settings:controller="com.android.settings.widget.VideoPreferenceController"
|
||||
android:persistent="false" />
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
<com.android.settings.widget.VideoPreference
|
||||
android:key="accessibility_control_timeout_video"
|
||||
android:title="@string/summary_placeholder"
|
||||
settings:animation="@raw/gesture_swipe_up"
|
||||
settings:preview="@drawable/gesture_swipe_up"
|
||||
settings:animation="@raw/accessibility_timeout"
|
||||
settings:preview="@drawable/accessibility_timeout"
|
||||
settings:controller="com.android.settings.widget.VideoPreferenceController"
|
||||
android:persistent="false" />
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public class Settings extends SettingsActivity {
|
||||
public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class CreateShortcutActivity extends SettingsActivity { /* empty */ }
|
||||
public static class FaceSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class FingerprintSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class SimSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class WifiTetherSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
|
||||
@@ -30,9 +30,11 @@ import androidx.annotation.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
|
||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||
import com.google.android.setupcompat.template.FooterButton;
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
/**
|
||||
* Activity which concludes fingerprint enrollment.
|
||||
@@ -40,6 +42,8 @@ import com.google.android.setupcompat.template.FooterButton;
|
||||
public class FingerprintEnrollFinish extends BiometricEnrollBase {
|
||||
|
||||
private static final String TAG = "FingerprintEnrollFinish";
|
||||
private static final String ACTION_FINGERPRINT_SETTINGS =
|
||||
"android.settings.FINGERPRINT_SETTINGS";
|
||||
@VisibleForTesting
|
||||
static final int REQUEST_ADD_ANOTHER = 1;
|
||||
@VisibleForTesting
|
||||
@@ -104,6 +108,11 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
|
||||
protected void onNextButtonClick(View view) {
|
||||
updateFingerprintSuggestionEnableState();
|
||||
setResult(RESULT_FINISHED);
|
||||
if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
|
||||
postEnroll();
|
||||
} else {
|
||||
launchFingerprintSettings();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -127,6 +136,24 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
|
||||
}
|
||||
}
|
||||
|
||||
private void postEnroll() {
|
||||
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
|
||||
if (fpm != null) {
|
||||
int result = fpm.postEnroll();
|
||||
if (result < 0) {
|
||||
Log.w(TAG, "postEnroll failed: result = " + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void launchFingerprintSettings() {
|
||||
final Intent intent = new Intent(ACTION_FINGERPRINT_SETTINGS);
|
||||
intent.setPackage(Utils.SETTINGS_PACKAGE_NAME);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void onAddAnotherButtonClick(View view) {
|
||||
startActivityForResult(getFingerprintEnrollingIntent(), REQUEST_ADD_ANOTHER);
|
||||
}
|
||||
|
||||
@@ -276,6 +276,9 @@ public class FingerprintSettings extends SubSettings {
|
||||
Activity activity = getActivity();
|
||||
mFingerprintManager = Utils.getFingerprintManagerOrNull(activity);
|
||||
|
||||
mToken = getIntent().getByteArrayExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||
|
||||
mAuthenticateSidecar = (FingerprintAuthenticateSidecar)
|
||||
getFragmentManager().findFragmentByTag(TAG_AUTHENTICATE_SIDECAR);
|
||||
if (mAuthenticateSidecar == null) {
|
||||
|
||||
@@ -54,6 +54,7 @@ import com.android.settings.backup.PrivacySettings;
|
||||
import com.android.settings.backup.ToggleBackupSettingFragment;
|
||||
import com.android.settings.backup.UserBackupSettingsActivity;
|
||||
import com.android.settings.biometrics.face.FaceSettings;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintSettings;
|
||||
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
|
||||
import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
|
||||
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
|
||||
@@ -203,6 +204,7 @@ public class SettingsGateway {
|
||||
AccountSyncSettings.class.getName(),
|
||||
AssistGestureSettings.class.getName(),
|
||||
FaceSettings.class.getName(),
|
||||
FingerprintSettings.FingerprintSettingsFragment.class.getName(),
|
||||
SwipeToNotificationSettings.class.getName(),
|
||||
DoubleTapPowerSettings.class.getName(),
|
||||
DoubleTapScreenSettings.class.getName(),
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.settings.fuelgauge;
|
||||
import static com.android.settings.fuelgauge.BatteryBroadcastReceiver.BatteryUpdateType;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
@@ -107,7 +108,8 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
BatteryTipPreferenceController mBatteryTipPreferenceController;
|
||||
private int mStatsType = BatteryStats.STATS_SINCE_CHARGED;
|
||||
|
||||
private final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
|
||||
@VisibleForTesting
|
||||
final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
restartBatteryInfoLoader();
|
||||
@@ -201,21 +203,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
getContentResolver().unregisterContentObserver(mSettingsObserver);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getContentResolver().registerContentObserver(
|
||||
Global.getUriFor(Global.BATTERY_ESTIMATES_LAST_UPDATE_TIME),
|
||||
false,
|
||||
mSettingsObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
@@ -251,6 +238,21 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
updateBatteryTipFlag(icicle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getContentResolver().registerContentObserver(
|
||||
Global.getUriFor(Global.BATTERY_ESTIMATES_LAST_UPDATE_TIME),
|
||||
false,
|
||||
mSettingsObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
getContentResolver().unregisterContentObserver(mSettingsObserver);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.FUELGAUGE_POWER_USAGE_SUMMARY_V2;
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.concurrent.TimeoutException;
|
||||
public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>> {
|
||||
|
||||
@VisibleForTesting
|
||||
static final int DEFAULT_CARD_COUNT = 4;
|
||||
static final int DEFAULT_CARD_COUNT = 2;
|
||||
static final int CARD_CONTENT_LOADER_ID = 1;
|
||||
|
||||
private static final String TAG = "ContextualCardLoader";
|
||||
@@ -141,42 +141,19 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// The maximum cards are four small cards OR
|
||||
// one large card with two small cards OR
|
||||
// two large cards
|
||||
if (visibleCards.size() <= 2 || getNumberOfLargeCard(visibleCards) == 0) {
|
||||
// four small cards
|
||||
return visibleCards;
|
||||
}
|
||||
if (!CardContentProvider.DELETE_CARD_URI.equals(mNotifyUri)) {
|
||||
final MetricsFeatureProvider metricsFeatureProvider =
|
||||
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
|
||||
|
||||
if (visibleCards.size() == DEFAULT_CARD_COUNT) {
|
||||
hiddenCards.add(visibleCards.remove(visibleCards.size() - 1));
|
||||
}
|
||||
metricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_CONTEXTUAL_CARD_SHOW,
|
||||
ContextualCardLogUtils.buildCardListLog(visibleCards));
|
||||
|
||||
if (getNumberOfLargeCard(visibleCards) == 1) {
|
||||
// One large card with two small cards
|
||||
return visibleCards;
|
||||
}
|
||||
|
||||
hiddenCards.add(visibleCards.remove(visibleCards.size() - 1));
|
||||
|
||||
// Two large cards
|
||||
return visibleCards;
|
||||
} finally {
|
||||
if (!CardContentProvider.DELETE_CARD_URI.equals(mNotifyUri)) {
|
||||
final MetricsFeatureProvider metricsFeatureProvider =
|
||||
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
|
||||
|
||||
metricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_CONTEXTUAL_CARD_SHOW,
|
||||
ContextualCardLogUtils.buildCardListLog(visibleCards));
|
||||
|
||||
metricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_CONTEXTUAL_CARD_NOT_SHOW,
|
||||
ContextualCardLogUtils.buildCardListLog(hiddenCards));
|
||||
}
|
||||
metricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_CONTEXTUAL_CARD_NOT_SHOW,
|
||||
ContextualCardLogUtils.buildCardListLog(hiddenCards));
|
||||
}
|
||||
return visibleCards;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -208,12 +185,6 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
return cards;
|
||||
}
|
||||
|
||||
private int getNumberOfLargeCard(List<ContextualCard> cards) {
|
||||
return (int) cards.stream()
|
||||
.filter(card -> isLargeCard(card))
|
||||
.count();
|
||||
}
|
||||
|
||||
private boolean isLargeCard(ContextualCard card) {
|
||||
return card.getSliceUri().equals(CONTEXTUAL_WIFI_SLICE_URI)
|
||||
|| card.getSliceUri().equals(BLUETOOTH_DEVICES_SLICE_URI)
|
||||
|
||||
@@ -459,7 +459,7 @@ public class NotificationChannelSlice implements CustomSliceable {
|
||||
private boolean isChannelConfigurable(NotificationChannel channel,
|
||||
NotificationBackend.AppRow appRow) {
|
||||
if (channel != null && appRow != null) {
|
||||
return !TextUtils.equals(channel.getId(), appRow.lockedChannelId);
|
||||
return !channel.isImportanceLockedByOEM();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.homepage.contextualcards.slices;
|
||||
|
||||
import android.app.role.RoleManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
|
||||
@@ -46,7 +47,7 @@ class NotificationMultiChannelAppRow implements Callable<NotificationBackend.App
|
||||
mPackageInfo.applicationInfo.packageName, mPackageInfo.applicationInfo.uid);
|
||||
if (channelCount > 1) {
|
||||
return mNotificationBackend.loadAppRow(mContext, mContext.getPackageManager(),
|
||||
mPackageInfo);
|
||||
mContext.getSystemService(RoleManager.class), mPackageInfo);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -123,11 +123,14 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends
|
||||
return new ComponentName(ci.packageName, ci.name);
|
||||
}
|
||||
// old service backed rule
|
||||
final String configurationActivity =
|
||||
ci.metaData.getString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY);
|
||||
if (configurationActivity != null) {
|
||||
return ComponentName.unflattenFromString(configurationActivity);
|
||||
if (ci.metaData != null) {
|
||||
final String configurationActivity = ci.metaData.getString(
|
||||
ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY);
|
||||
if (configurationActivity != null) {
|
||||
return ComponentName.unflattenFromString(configurationActivity);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,13 +54,7 @@ public class BlockPreferenceController extends NotificationPreferenceController
|
||||
if (mAppRow == null) {
|
||||
return false;
|
||||
}
|
||||
if (mChannel != null) {
|
||||
return isChannelBlockable();
|
||||
} else if (mChannelGroup != null) {
|
||||
return isChannelGroupBlockable();
|
||||
} else {
|
||||
return !mAppRow.systemApp || (mAppRow.systemApp && mAppRow.banned);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateState(Preference preference) {
|
||||
@@ -78,6 +72,19 @@ public class BlockPreferenceController extends NotificationPreferenceController
|
||||
}
|
||||
bar.setDisabledByAdmin(mAdmin);
|
||||
|
||||
if (mChannel != null && !isChannelBlockable()) {
|
||||
bar.setEnabled(false);
|
||||
}
|
||||
|
||||
if (mChannelGroup != null && !isChannelGroupBlockable()) {
|
||||
bar.setEnabled(false);
|
||||
}
|
||||
|
||||
if (mChannel == null && mAppRow.systemApp
|
||||
&& (!mAppRow.banned || mAppRow.lockedImportance)) {
|
||||
bar.setEnabled(false);
|
||||
}
|
||||
|
||||
if (mChannel != null) {
|
||||
bar.setChecked(!mAppRow.banned
|
||||
&& mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mAppRow != null && mChannel != null) {
|
||||
preference.setEnabled(mAdmin == null && isChannelBlockable());
|
||||
preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
|
||||
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setChecked(mChannel.getImportance() >= IMPORTANCE_HIGH);
|
||||
|
||||
@@ -59,9 +59,9 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mAppRow!= null && mChannel != null) {
|
||||
preference.setEnabled(mAdmin == null && isChannelBlockable());
|
||||
preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
|
||||
ImportancePreference pref = (ImportancePreference) preference;
|
||||
pref.setConfigurable(isChannelBlockable());
|
||||
pref.setConfigurable(!mChannel.isImportanceLockedByOEM());
|
||||
pref.setImportance(mChannel.getImportance());
|
||||
pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
|
||||
// TODO: b/128445911 pass along lock screen setting
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mAppRow != null && mChannel != null) {
|
||||
preference.setEnabled(mAdmin == null && isChannelBlockable());
|
||||
preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
|
||||
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setChecked(mChannel.getImportance() == IMPORTANCE_MIN);
|
||||
|
||||
@@ -21,6 +21,7 @@ import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
|
||||
import android.app.INotificationManager;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationChannelGroup;
|
||||
import android.app.role.RoleManager;
|
||||
import android.app.usage.IUsageStatsManager;
|
||||
import android.app.usage.UsageEvents;
|
||||
import android.content.ComponentName;
|
||||
@@ -86,14 +87,22 @@ public class NotificationBackend {
|
||||
return !systemApp || (systemApp && blocked);
|
||||
}
|
||||
|
||||
public AppRow loadAppRow(Context context, PackageManager pm, PackageInfo app) {
|
||||
public AppRow loadAppRow(Context context, PackageManager pm,
|
||||
RoleManager roleManager, PackageInfo app) {
|
||||
final AppRow row = loadAppRow(context, pm, app.applicationInfo);
|
||||
recordCanBeBlocked(context, pm, app, row);
|
||||
recordCanBeBlocked(context, pm, roleManager, app, row);
|
||||
return row;
|
||||
}
|
||||
|
||||
void recordCanBeBlocked(Context context, PackageManager pm, PackageInfo app, AppRow row) {
|
||||
void recordCanBeBlocked(Context context, PackageManager pm, RoleManager rm, PackageInfo app,
|
||||
AppRow row) {
|
||||
row.systemApp = Utils.isSystemPackage(context.getResources(), pm, app);
|
||||
List<String> roles = rm.getHeldRolesFromController(app.packageName);
|
||||
if (roles.contains(RoleManager.ROLE_SMS)
|
||||
|| roles.contains(RoleManager.ROLE_DIALER)
|
||||
|| roles.contains(RoleManager.ROLE_EMERGENCY)) {
|
||||
row.systemApp = true;
|
||||
}
|
||||
final String[] nonBlockablePkgs = context.getResources().getStringArray(
|
||||
com.android.internal.R.array.config_nonBlockableNotificationPackages);
|
||||
markAppRowWithBlockables(nonBlockablePkgs, row, app.packageName);
|
||||
@@ -108,10 +117,8 @@ public class NotificationBackend {
|
||||
if (pkg == null) {
|
||||
continue;
|
||||
} else if (pkg.contains(":")) {
|
||||
// Interpret as channel; lock only this channel for this app.
|
||||
if (packageName.equals(pkg.split(":", 2)[0])) {
|
||||
row.lockedChannelId = pkg.split(":", 2 )[1];
|
||||
}
|
||||
// handled by NotificationChannel.isImportanceLockedByOEM()
|
||||
continue;
|
||||
} else if (packageName.equals(nonBlockablePkgs[i])) {
|
||||
row.systemApp = row.lockedImportance = true;
|
||||
}
|
||||
@@ -123,8 +130,9 @@ public class NotificationBackend {
|
||||
try {
|
||||
PackageInfo info = context.getPackageManager().getPackageInfo(
|
||||
app.packageName, PackageManager.GET_SIGNATURES);
|
||||
RoleManager rm = context.getSystemService(RoleManager.class);
|
||||
final AppRow row = new AppRow();
|
||||
recordCanBeBlocked(context, context.getPackageManager(), info, row);
|
||||
recordCanBeBlocked(context, context.getPackageManager(), rm, info, row);
|
||||
return row.systemApp;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
@@ -491,7 +499,6 @@ public class NotificationBackend {
|
||||
public boolean first; // first app in section
|
||||
public boolean systemApp;
|
||||
public boolean lockedImportance;
|
||||
public String lockedChannelId;
|
||||
public boolean showBadge;
|
||||
public boolean allowBubbles;
|
||||
public int userId;
|
||||
|
||||
@@ -110,27 +110,13 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isChannelConfigurable() {
|
||||
if (mAppRow != null && mAppRow.lockedImportance) {
|
||||
return false;
|
||||
}
|
||||
if (mChannel != null && mAppRow != null) {
|
||||
return !Objects.equals(mChannel.getId(), mAppRow.lockedChannelId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isChannelBlockable() {
|
||||
if (mChannel != null && mAppRow != null) {
|
||||
if (!isChannelConfigurable()) {
|
||||
if (mChannel.isImportanceLockedByCriticalDeviceFunction()
|
||||
|| mChannel.isImportanceLockedByOEM()) {
|
||||
return mChannel.getImportance() == IMPORTANCE_NONE;
|
||||
}
|
||||
|
||||
if (mChannel.isImportanceLockedByOEM()
|
||||
|| mChannel.isImportanceLockedByCriticalDeviceFunction()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mChannel.isBlockableSystem() || !mAppRow.systemApp
|
||||
|| mChannel.getImportance() == IMPORTANCE_NONE;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationChannelGroup;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.role.RoleManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -36,7 +37,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.BlendMode;
|
||||
import android.graphics.BlendModeColorFilter;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
@@ -71,6 +71,7 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
|
||||
protected PackageManager mPm;
|
||||
protected NotificationBackend mBackend = new NotificationBackend();
|
||||
protected NotificationManager mNm;
|
||||
protected RoleManager mRm;
|
||||
protected Context mContext;
|
||||
|
||||
protected int mUid;
|
||||
@@ -101,6 +102,7 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
|
||||
|
||||
mPm = getPackageManager();
|
||||
mNm = NotificationManager.from(mContext);
|
||||
mRm = mContext.getSystemService(RoleManager.class);
|
||||
|
||||
mPkg = mArgs != null && mArgs.containsKey(AppInfoBase.ARG_PACKAGE_NAME)
|
||||
? mArgs.getString(AppInfoBase.ARG_PACKAGE_NAME)
|
||||
@@ -195,7 +197,7 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
|
||||
}
|
||||
|
||||
private void loadAppRow() {
|
||||
mAppRow = mBackend.loadAppRow(mContext, mPm, mPkgInfo);
|
||||
mAppRow = mBackend.loadAppRow(mContext, mPm, mRm, mPkgInfo);
|
||||
}
|
||||
|
||||
private void loadChannelGroup() {
|
||||
@@ -342,7 +344,7 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
|
||||
|
||||
protected boolean isChannelConfigurable(NotificationChannel channel) {
|
||||
if (channel != null && mAppRow != null) {
|
||||
return !channel.getId().equals(mAppRow.lockedChannelId);
|
||||
return !channel.isImportanceLockedByOEM();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -353,6 +355,14 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (channel.isImportanceLockedByCriticalDeviceFunction()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (channel.isImportanceLockedByOEM()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return channel.isBlockableSystem()
|
||||
|| channel.getImportance() == NotificationManager.IMPORTANCE_NONE;
|
||||
}
|
||||
|
||||
@@ -60,16 +60,18 @@ public class WifiDialogActivity extends Activity implements WifiDialog.WifiDialo
|
||||
|
||||
private WifiDialog mDialog;
|
||||
|
||||
private Intent mIntent;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
final Intent intent = getIntent();
|
||||
if (WizardManagerHelper.isSetupWizardIntent(intent)) {
|
||||
setTheme(SetupWizardUtils.getTransparentTheme(intent));
|
||||
mIntent = getIntent();
|
||||
if (WizardManagerHelper.isSetupWizardIntent(mIntent)) {
|
||||
setTheme(SetupWizardUtils.getTransparentTheme(mIntent));
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final Bundle accessPointState = intent.getBundleExtra(KEY_ACCESS_POINT_STATE);
|
||||
final Bundle accessPointState = mIntent.getBundleExtra(KEY_ACCESS_POINT_STATE);
|
||||
AccessPoint accessPoint = null;
|
||||
if (accessPointState != null) {
|
||||
accessPoint = new AccessPoint(this, accessPointState);
|
||||
@@ -175,9 +177,11 @@ public class WifiDialogActivity extends Activity implements WifiDialog.WifiDialo
|
||||
|
||||
@Override
|
||||
public void onScan(WifiDialog dialog, String ssid) {
|
||||
Intent intent = WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid);
|
||||
WizardManagerHelper.copyWizardManagerExtras(mIntent, intent);
|
||||
|
||||
// Launch QR code scanner to join a network.
|
||||
startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
|
||||
REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
|
||||
startActivityForResult(intent, REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.settings.wifi.dpp;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -30,6 +29,8 @@ import androidx.fragment.app.FragmentTransaction;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.InstrumentedActivity;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
/**
|
||||
* To provision "this" device with specified Wi-Fi network.
|
||||
*
|
||||
@@ -54,6 +55,10 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
|
||||
setTheme(R.style.LightTheme_SettingsBase_SetupWizard);
|
||||
}
|
||||
|
||||
setContentView(R.layout.wifi_dpp_activity);
|
||||
mFragmentManager = getSupportFragmentManager();
|
||||
|
||||
|
||||
@@ -33,16 +33,20 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.os.BatterySipper;
|
||||
import com.android.internal.os.BatteryStatsHelper;
|
||||
@@ -51,6 +55,7 @@ import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -66,6 +71,7 @@ import org.mockito.stubbing.Answer;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -117,6 +123,14 @@ public class PowerUsageSummaryTest {
|
||||
private MenuItem mAdvancedPageMenu;
|
||||
@Mock
|
||||
private BatteryInfo mBatteryInfo;
|
||||
@Mock
|
||||
private ContentResolver mContentResolver;
|
||||
@Mock
|
||||
private BatteryBroadcastReceiver mBatteryBroadcastReceiver;
|
||||
@Mock
|
||||
private VisibilityLoggerMixin mVisibilityLoggerMixin;
|
||||
@Mock
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
|
||||
private List<BatterySipper> mUsageList;
|
||||
private Context mRealContext;
|
||||
@@ -148,7 +162,7 @@ public class PowerUsageSummaryTest {
|
||||
.thenReturn(sAdditionalBatteryInfoIntent);
|
||||
when(mBatteryHelper.getTotalPower()).thenReturn(TOTAL_POWER);
|
||||
when(mBatteryHelper.getStats().computeBatteryRealtime(anyLong(), anyInt()))
|
||||
.thenReturn(TIME_SINCE_LAST_FULL_CHARGE_US);
|
||||
.thenReturn(TIME_SINCE_LAST_FULL_CHARGE_US);
|
||||
|
||||
when(mNormalBatterySipper.getUid()).thenReturn(UID);
|
||||
mNormalBatterySipper.totalPowerMah = POWER_MAH;
|
||||
@@ -176,6 +190,11 @@ public class PowerUsageSummaryTest {
|
||||
mFragment.mScreenUsagePref = mScreenUsagePref;
|
||||
mFragment.mLastFullChargePref = mLastFullChargePref;
|
||||
mFragment.mBatteryUtils = spy(new BatteryUtils(mRealContext));
|
||||
ReflectionHelpers.setField(mFragment, "mVisibilityLoggerMixin", mVisibilityLoggerMixin);
|
||||
ReflectionHelpers.setField(mFragment, "mBatteryBroadcastReceiver",
|
||||
mBatteryBroadcastReceiver);
|
||||
doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
|
||||
when(mFragment.getContentResolver()).thenReturn(mContentResolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,10 +226,10 @@ public class PowerUsageSummaryTest {
|
||||
public void nonIndexableKeys_MatchPreferenceKeys() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
final List<String> niks =
|
||||
PowerUsageSummary.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(context);
|
||||
PowerUsageSummary.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(context);
|
||||
|
||||
final List<String> keys =
|
||||
XmlTestUtils.getKeysFromPreferenceXml(context, R.xml.power_usage_summary);
|
||||
XmlTestUtils.getKeysFromPreferenceXml(context, R.xml.power_usage_summary);
|
||||
|
||||
assertThat(keys).containsAllIn(niks);
|
||||
}
|
||||
@@ -223,25 +242,25 @@ public class PowerUsageSummaryTest {
|
||||
mFragment.restartBatteryTipLoader();
|
||||
|
||||
verify(mLoaderManager)
|
||||
.restartLoader(eq(PowerUsageSummary.BATTERY_TIP_LOADER), eq(Bundle.EMPTY), any());
|
||||
.restartLoader(eq(PowerUsageSummary.BATTERY_TIP_LOADER), eq(Bundle.EMPTY), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showBothEstimates_summariesAreBothModified() {
|
||||
when(mFeatureFactory.powerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(any()))
|
||||
.thenReturn(true);
|
||||
.thenReturn(true);
|
||||
doAnswer(new Answer() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) {
|
||||
return mRealContext.getString(
|
||||
R.string.power_usage_old_debug, invocation.getArguments()[0]);
|
||||
R.string.power_usage_old_debug, invocation.getArguments()[0]);
|
||||
}
|
||||
}).when(mFeatureFactory.powerUsageFeatureProvider).getOldEstimateDebugString(any());
|
||||
doAnswer(new Answer() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) {
|
||||
return mRealContext.getString(
|
||||
R.string.power_usage_enhanced_debug, invocation.getArguments()[0]);
|
||||
R.string.power_usage_enhanced_debug, invocation.getArguments()[0]);
|
||||
}
|
||||
}).when(mFeatureFactory.powerUsageFeatureProvider).getEnhancedEstimateDebugString(any());
|
||||
|
||||
@@ -336,6 +355,24 @@ public class PowerUsageSummaryTest {
|
||||
verify(mFragment).restartBatteryTipLoader();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_registerContentObserver() {
|
||||
mFragment.onResume();
|
||||
|
||||
verify(mContentResolver).registerContentObserver(
|
||||
Settings.Global.getUriFor(Settings.Global.BATTERY_ESTIMATES_LAST_UPDATE_TIME),
|
||||
false,
|
||||
mFragment.mSettingsObserver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPause_unregisterContentObserver() {
|
||||
mFragment.onPause();
|
||||
|
||||
verify(mContentResolver).unregisterContentObserver(
|
||||
mFragment.mSettingsObserver);
|
||||
}
|
||||
|
||||
public static class TestFragment extends PowerUsageSummary {
|
||||
private Context mContext;
|
||||
|
||||
@@ -348,6 +385,12 @@ public class PowerUsageSummaryTest {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ContentResolver getContentResolver() {
|
||||
// Override it so we can access this method in test
|
||||
return super.getContentResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
void showBothEstimates() {
|
||||
List<BatteryInfo> fakeBatteryInfo = new ArrayList<>(2);
|
||||
|
||||
@@ -60,6 +60,14 @@ public class ContextualCardLoaderTest {
|
||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadInBackground_legacyMode_shouldReturnNothing() {
|
||||
assertThat(mContext.getResources().getBoolean(R.bool.config_use_legacy_suggestion))
|
||||
.isTrue();
|
||||
|
||||
assertThat(mContextualCardLoader.loadInBackground()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDisplayableCards_twoEligibleCards_shouldShowAll() {
|
||||
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
|
||||
@@ -72,53 +80,16 @@ public class ContextualCardLoaderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDisplayableCards_fiveEligibleCardsNoLarge_shouldShowDefaultCardCount() {
|
||||
final List<ContextualCard> fiveCards = getContextualCardListWithNoLargeCard();
|
||||
doReturn(fiveCards).when(mContextualCardLoader).filterEligibleCards(anyList());
|
||||
public void getDisplayableCards_fourEligibleCards_shouldShowDefaultCardCount() {
|
||||
final List<ContextualCard> fourCards = getContextualCardList();
|
||||
doReturn(fourCards).when(mContextualCardLoader).filterEligibleCards(anyList());
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(
|
||||
fiveCards);
|
||||
final List<ContextualCard> result = mContextualCardLoader
|
||||
.getDisplayableCards(fourCards);
|
||||
|
||||
assertThat(result).hasSize(DEFAULT_CARD_COUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDisplayableCards_threeEligibleCardsOneLarge_shouldShowThreeCards() {
|
||||
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
|
||||
.collect(Collectors.toList());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_gesture")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(Uri.parse(
|
||||
"content://com.android.settings.test.slices/action/gesture_pick_up"))
|
||||
.build());
|
||||
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(anyList());
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
|
||||
|
||||
assertThat(result).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDisplayableCards_threeEligibleCardsTwoLarge_shouldShowTwoCards() {
|
||||
final List<ContextualCard> threeCards = getContextualCardList().stream().limit(3)
|
||||
.collect(Collectors.toList());
|
||||
doReturn(threeCards).when(mContextualCardLoader).filterEligibleCards(anyList());
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(
|
||||
threeCards);
|
||||
|
||||
assertThat(result).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadInBackground_legacyMode_shouldReturnNothing() {
|
||||
assertThat(mContext.getResources().getBoolean(R.bool.config_use_legacy_suggestion))
|
||||
.isTrue();
|
||||
|
||||
assertThat(mContextualCardLoader.loadInBackground()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDisplayableCards_refreshCardUri_shouldLogContextualCardDisplay() {
|
||||
mContextualCardLoader.mNotifyUri = CardContentProvider.REFRESH_CARD_URI;
|
||||
@@ -167,32 +138,4 @@ public class ContextualCardLoaderTest {
|
||||
.build());
|
||||
return cards;
|
||||
}
|
||||
|
||||
private List<ContextualCard> getContextualCardListWithNoLargeCard() {
|
||||
final List<ContextualCard> cards = new ArrayList<>();
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_rotate")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(
|
||||
Uri.parse("content://com.android.settings.test.slices/action/auto_rotate"))
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_flashlight")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(
|
||||
Uri.parse("content://com.android.settings.test.slices/action/flashlight"))
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_bt")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(Uri.parse("content://android.settings.test.slices/action/bluetooth"))
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_gesture")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(Uri.parse(
|
||||
"content://com.android.settings.test.slices/action/gesture_pick_up"))
|
||||
.build());
|
||||
return cards;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationChannelGroup;
|
||||
import android.app.role.RoleManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
@@ -345,7 +346,7 @@ public class NotificationChannelSliceTest {
|
||||
doReturn(buildNotificationChannelGroups(channels)).when(mNotificationBackend).getGroups(
|
||||
any(String.class), any(int.class));
|
||||
doReturn(appRow).when(mNotificationBackend).loadAppRow(any(Context.class),
|
||||
any(PackageManager.class), any(PackageInfo.class));
|
||||
any(PackageManager.class), any(RoleManager.class), any(PackageInfo.class));
|
||||
doReturn(channelCount).when(mNotificationBackend).getChannelCount(
|
||||
any(String.class), any(int.class));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.role.RoleManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
@@ -65,7 +66,7 @@ public class NotificationMultiChannelAppRowTest {
|
||||
mNotificationMultiChannelAppRow.call();
|
||||
|
||||
verify(mNotificationBackend).loadAppRow(any(Context.class), any(PackageManager.class),
|
||||
any(PackageInfo.class));
|
||||
any(RoleManager.class), any(PackageInfo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -76,6 +77,6 @@ public class NotificationMultiChannelAppRowTest {
|
||||
mNotificationMultiChannelAppRow.call();
|
||||
|
||||
verify(mNotificationBackend, never()).loadAppRow(any(Context.class),
|
||||
any(PackageManager.class), any(PackageInfo.class));
|
||||
any(PackageManager.class), any(RoleManager.class), any(PackageInfo.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,12 +139,11 @@ public class AllowSoundPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_notBlockable() {
|
||||
String lockedId = "locked";
|
||||
public void testUpdateState_notBlockable_oem() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.getId()).thenReturn("");
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(mContext);
|
||||
|
||||
@@ -188,11 +188,10 @@ public class BadgePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_channelNotBlockable() {
|
||||
String lockedId = "locked";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.getId()).thenReturn("");
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(mContext);
|
||||
@@ -204,7 +203,6 @@ public class BadgePreferenceControllerTest {
|
||||
@Test
|
||||
public void testUpdateState_channel() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = "a";
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.canShowBadge()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
@@ -101,23 +101,23 @@ public class BlockPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable_notIfChannelNotBlockable() {
|
||||
public void testIsAvailable_channelNotBlockable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertFalse(mController.isAvailable());
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable_notIfChannelNonDefault() {
|
||||
public void testIsAvailable_channelNonDefault() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertFalse(mController.isAvailable());
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,19 +131,19 @@ public class BlockPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable_notIfGroupNotBlockable() {
|
||||
public void testIsAvailable_GroupNotBlockable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null);
|
||||
assertFalse(mController.isAvailable());
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable_notIfAppNotBlockable() {
|
||||
public void testIsAvailable_AppNotBlockable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
mController.onResume(appRow, null, null, null);
|
||||
assertFalse(mController.isAvailable());
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,13 +160,99 @@ public class BlockPreferenceControllerTest {
|
||||
public void testIsAvailable_nonSystemApp() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = false;
|
||||
appRow.lockedChannelId = "not this";
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_lockedApp() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedImportance = true;
|
||||
appRow.systemApp = true;
|
||||
mController.onResume(appRow, null, null, null);
|
||||
mController.updateState(mPreference);
|
||||
assertFalse(mSwitch.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_GroupNotBlockable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null);
|
||||
mController.updateState(mPreference);
|
||||
assertFalse(mSwitch.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_systemAppNotBlockable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
mController.onResume(appRow, null, null, null);
|
||||
mController.updateState(mPreference);
|
||||
assertFalse(mSwitch.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_systemAppBlockable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
|
||||
channel.setBlockableSystem(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
mController.updateState(mPreference);
|
||||
assertTrue(mSwitch.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_lockedChannel() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertFalse(mSwitch.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_defaultAppChannel() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertFalse(mSwitch.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_channel() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertTrue(mSwitch.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_app() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
mController.onResume(appRow, null, null, null);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertTrue(mSwitch.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_app() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
|
||||
@@ -203,11 +203,9 @@ public class BubblePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_channelNotBlockable() {
|
||||
String lockedId = "locked";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(mContext);
|
||||
@@ -219,7 +217,6 @@ public class BubblePreferenceControllerTest {
|
||||
@Test
|
||||
public void testUpdateState_channel() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = "a";
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.canBubble()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
@@ -111,11 +111,9 @@ public class DndPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_notBlockable() {
|
||||
String lockedId = "locked";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
|
||||
|
||||
@@ -142,11 +142,9 @@ public class HighImportancePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_notConfigurable() {
|
||||
String lockedId = "locked";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
@@ -156,6 +154,36 @@ public class HighImportancePreferenceControllerTest {
|
||||
assertFalse(pref.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_systemButConfigurable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(false);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(mContext, null);
|
||||
mController.updateState(pref);
|
||||
|
||||
assertTrue(pref.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_defaultApp() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(mContext, null);
|
||||
mController.updateState(pref);
|
||||
|
||||
assertTrue(pref.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_high() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
|
||||
@@ -159,11 +159,9 @@ public class ImportancePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_notConfigurable() {
|
||||
String lockedId = "locked";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
@@ -173,6 +171,36 @@ public class ImportancePreferenceControllerTest {
|
||||
assertFalse(pref.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_systemButConfigurable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(false);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new ImportancePreference(mContext, null);
|
||||
mController.updateState(pref);
|
||||
|
||||
assertTrue(pref.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_defaultApp() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new ImportancePreference(mContext, null);
|
||||
mController.updateState(pref);
|
||||
|
||||
assertTrue(pref.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
|
||||
@@ -159,11 +159,9 @@ public class LightsPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_notBlockable() {
|
||||
String lockedId = "locked";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(mContext);
|
||||
|
||||
@@ -142,11 +142,9 @@ public class MinImportancePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_notConfigurable() {
|
||||
String lockedId = "locked";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
@@ -156,6 +154,36 @@ public class MinImportancePreferenceControllerTest {
|
||||
assertFalse(pref.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_systemButConfigurable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(false);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(mContext, null);
|
||||
mController.updateState(pref);
|
||||
|
||||
assertTrue(pref.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_defaultApp() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = true;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(mContext, null);
|
||||
mController.updateState(pref);
|
||||
|
||||
assertTrue(pref.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_min() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
|
||||
@@ -18,22 +18,28 @@ package com.android.settings.notification;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.role.RoleManager;
|
||||
import android.app.usage.UsageEvents;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Parcel;
|
||||
|
||||
import com.android.settings.notification.NotificationBackend.AppRow;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class NotificationBackendTest {
|
||||
@@ -50,81 +56,40 @@ public class NotificationBackendTest {
|
||||
|
||||
// This package has a package lock but no locked channels
|
||||
assertTrue(appRow.lockedImportance);
|
||||
assertNull(appRow.lockedChannelId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAppRow_unblockableChannelOrPkg() {
|
||||
String channelBlockName = "foo.bar.pkgWithChannel";
|
||||
String pkgBlockName = "foo.bar.pkgBlock";
|
||||
String[] nonBlockablePkgs = new String[2];
|
||||
nonBlockablePkgs[0] = pkgBlockName;
|
||||
nonBlockablePkgs[1] = channelBlockName + ":SpecificChannel";
|
||||
public void testMarkAppRow_defaultPackage() {
|
||||
PackageInfo pi = new PackageInfo();
|
||||
pi.packageName = "test";
|
||||
pi.applicationInfo = new ApplicationInfo();
|
||||
pi.applicationInfo.packageName = "test";
|
||||
List<String> roles = new ArrayList<>();
|
||||
roles.add(RoleManager.ROLE_DIALER);
|
||||
RoleManager rm = mock(RoleManager.class);
|
||||
when(rm.getHeldRolesFromController(anyString())).thenReturn(roles);
|
||||
|
||||
// This package has a channel level lock but no full package lock
|
||||
AppRow channelBlockApp = new AppRow();
|
||||
channelBlockApp.pkg = channelBlockName;
|
||||
NotificationBackend.markAppRowWithBlockables(nonBlockablePkgs, channelBlockApp,
|
||||
channelBlockName);
|
||||
assertFalse(channelBlockApp.lockedImportance);
|
||||
assertEquals("SpecificChannel", channelBlockApp.lockedChannelId);
|
||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
||||
mock(PackageManager.class), rm, pi);
|
||||
|
||||
// This other package has the reverse
|
||||
AppRow pkgBlock = new AppRow();
|
||||
pkgBlock.pkg = pkgBlockName;
|
||||
NotificationBackend.markAppRowWithBlockables(nonBlockablePkgs, pkgBlock, pkgBlockName);
|
||||
assertTrue(pkgBlock.lockedImportance);
|
||||
assertNull(pkgBlock.lockedChannelId);
|
||||
|
||||
// This third package has no locks at all
|
||||
AppRow otherAppRow = new AppRow();
|
||||
otherAppRow.pkg ="foo.bar.nothingBlocked";
|
||||
NotificationBackend.markAppRowWithBlockables(nonBlockablePkgs, otherAppRow,
|
||||
"foo.bar.nothingBlocked");
|
||||
assertFalse(otherAppRow.lockedImportance);
|
||||
assertNull(otherAppRow.lockedChannelId);
|
||||
assertTrue(appRow.systemApp);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAppRow_unblockableChannelAndPkg() {
|
||||
AppRow appRow = new AppRow();
|
||||
String packageName = "foo.bar.unblockable";
|
||||
appRow.pkg = packageName;
|
||||
String[] nonBlockablePkgs = new String[2];
|
||||
nonBlockablePkgs[0] = "foo.bar.unblockable";
|
||||
nonBlockablePkgs[1] = "foo.bar.unblockable:SpecificChannel";
|
||||
NotificationBackend.markAppRowWithBlockables(nonBlockablePkgs, appRow, packageName);
|
||||
public void testMarkAppRow_notDefaultPackage() {
|
||||
PackageInfo pi = new PackageInfo();
|
||||
pi.packageName = "test";
|
||||
pi.applicationInfo = new ApplicationInfo();
|
||||
pi.applicationInfo.packageName = "test";
|
||||
List<String> roles = new ArrayList<>();
|
||||
roles.add(RoleManager.ROLE_HOME);
|
||||
RoleManager rm = mock(RoleManager.class);
|
||||
when(rm.getHeldRolesFromController(anyString())).thenReturn(roles);
|
||||
|
||||
// This package has both a channel lock and a package lock
|
||||
assertTrue(appRow.lockedImportance);
|
||||
assertEquals("SpecificChannel", appRow.lockedChannelId);
|
||||
}
|
||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
||||
mock(PackageManager.class), rm, pi);
|
||||
|
||||
@Test
|
||||
public void testMarkAppRow_channelNameWithColons() {
|
||||
AppRow appRow = new AppRow();
|
||||
String packageName = "foo.bar.unblockable";
|
||||
String channelName = "SpecificChannel:1234:abc:defg";
|
||||
appRow.pkg = packageName;
|
||||
String[] nonBlockablePkgs = new String[1];
|
||||
nonBlockablePkgs[0] = packageName + ":" + channelName;
|
||||
NotificationBackend.markAppRowWithBlockables(nonBlockablePkgs, appRow, packageName);
|
||||
|
||||
assertEquals(channelName, appRow.lockedChannelId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAppRow_blocklistWithNullEntries() {
|
||||
AppRow appRow = new AppRow();
|
||||
String packageName = "foo.bar.unblockable";
|
||||
appRow.pkg = packageName;
|
||||
String[] nonBlockablePkgs = new String[6]; // extra long list with some entries left null
|
||||
nonBlockablePkgs[2] = "foo.bar.unblockable";
|
||||
nonBlockablePkgs[4] = "foo.bar.unblockable:SpecificChannel";
|
||||
NotificationBackend.markAppRowWithBlockables(nonBlockablePkgs, appRow, packageName);
|
||||
|
||||
assertTrue(appRow.lockedImportance);
|
||||
assertEquals("SpecificChannel", appRow.lockedChannelId);
|
||||
assertFalse(appRow.systemApp);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -203,36 +203,29 @@ public class NotificationPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsBlockable_channelLevelWhitelist() {
|
||||
String sameId = "bananas";
|
||||
public void testIsBlockable_oemWhitelist() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = sameId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(sameId);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
|
||||
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertFalse(mController.isChannelBlockable());
|
||||
|
||||
when(channel.getId()).thenReturn("something new");
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(false);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertTrue(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsBlockable_appLevelWhitelist() {
|
||||
public void testIsBlockable_defaultApp() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = "something";
|
||||
appRow.lockedImportance = true;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
|
||||
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
|
||||
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertFalse(mController.isChannelBlockable());
|
||||
|
||||
appRow.lockedImportance = false;
|
||||
mController.onResume(appRow, mock(NotificationChannel.class), null, null);
|
||||
assertTrue(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -281,34 +274,6 @@ public class NotificationPreferenceControllerTest {
|
||||
assertTrue(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChannelBlockable_notConfigurable() {
|
||||
String sameId = "apples";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = false;
|
||||
appRow.lockedChannelId = sameId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(sameId);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
|
||||
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertFalse(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChannelBlockable_notConfigurableButBlocked() {
|
||||
String sameId = "apples";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = false;
|
||||
appRow.lockedChannelId = sameId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(sameId);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
|
||||
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertTrue(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChannelGroupBlockable_nonSystemBlockable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
|
||||
@@ -162,11 +162,9 @@ public class SoundPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_notBlockable() {
|
||||
String lockedId = "locked";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
||||
|
||||
@@ -141,11 +141,9 @@ public class VibrationPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_notBlockable() {
|
||||
String lockedId = "locked";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = lockedId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(lockedId);
|
||||
when(channel.isImportanceLockedByOEM()).thenReturn(true);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
|
||||
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
|
||||
import com.android.settings.testutils.shadow.ShadowWifiManager;
|
||||
import com.android.settings.wifi.dpp.WifiDppEnrolleeActivity;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
@@ -37,6 +38,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.android.controller.ActivityController;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@@ -111,4 +113,23 @@ public class WifiDialogActivityTest {
|
||||
assertThat(dialog.getContext().getThemeResId())
|
||||
.isEqualTo(R.style.SuwAlertDialogThemeCompat_Light);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onScan_whenLaunchFromDeferredSetup_shouldApplyLightTheme() {
|
||||
ActivityController<WifiDppEnrolleeActivity> controller = Robolectric.buildActivity(
|
||||
WifiDppEnrolleeActivity.class,
|
||||
new Intent()
|
||||
.setAction(WifiDppEnrolleeActivity.ACTION_ENROLLEE_QR_CODE_SCANNER)
|
||||
.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true)
|
||||
.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)
|
||||
);
|
||||
controller.create();
|
||||
|
||||
Intent intent = controller.getIntent();
|
||||
assertThat(intent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, false)).isTrue();
|
||||
assertThat(intent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, false)).isTrue();
|
||||
|
||||
assertThat(controller.get().getThemeResId()).
|
||||
isEqualTo(R.style.LightTheme_SettingsBase_SetupWizard);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user