Snap for 5591454 from ce8495d632 to qt-qpr1-release
Change-Id: Ie62ae47ec2a85a54037561f53a460b04b4bd8fca
This commit is contained in:
@@ -2403,16 +2403,6 @@
|
||||
android:excludeFromRecents="true">
|
||||
</activity>
|
||||
|
||||
<activity android:name=".SmsDefaultDialog"
|
||||
android:label="@string/sms_application_title"
|
||||
android:excludeFromRecents="true"
|
||||
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert">
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.provider.Telephony.ACTION_CHANGE_DEFAULT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="Settings$NotificationAccessSettingsActivity"
|
||||
android:label="@string/manage_notification_access_title"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@android:color/white"/>
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/circle_outline_color"/>
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="@dimen/qrcode_preview_size"
|
||||
android:layout_height="@dimen/qrcode_preview_size">
|
||||
android:layout_height="@dimen/qrcode_preview_size"
|
||||
android:clipChildren="true">
|
||||
<TextureView
|
||||
android:id="@+id/preview_view"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/gestures_setting_background_color"
|
||||
android:clipToPadding="false"
|
||||
android:clipChildren="true"
|
||||
android:gravity="center"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:orientation="horizontal"
|
||||
|
||||
@@ -882,17 +882,17 @@
|
||||
<string name="security_dashboard_summary_no_fingerprint">Screen lock</string>
|
||||
|
||||
<!-- Face enrollment and settings --><skip />
|
||||
<!-- Message shown in summary field when face authentication is set up. [CHAR LIMIT=40] -->
|
||||
<!-- Message shown in summary field when face unlock is set up. [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_face_preference_summary">Face added</string>
|
||||
<!-- Message shown in summary field when face authentication is not set up. [CHAR LIMIT=54] -->
|
||||
<string name="security_settings_face_preference_summary_none">Tap to set up face authentication</string>
|
||||
<!-- Message shown in summary field when face unlock is not set up. [CHAR LIMIT=54] -->
|
||||
<string name="security_settings_face_preference_summary_none">Tap to set up face unlock</string>
|
||||
<!-- Title shown for menu item that launches face settings or enrollment. [CHAR LIMIT=32] -->
|
||||
<string name="security_settings_face_preference_title">Face authentication</string>
|
||||
<string name="security_settings_face_preference_title">Face unlock</string>
|
||||
<!-- Introduction title shown in face enrollment education screen [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_face_enroll_education_title">How to set up Face unlock</string>
|
||||
<string name="security_settings_face_enroll_education_title">How to set up face unlock</string>
|
||||
<!-- Introduction title shown in face enrollment education screen for accessibility [CHAR LIMI=40]-->
|
||||
<string name="security_settings_face_enroll_education_title_accessibility">Set up Face unlock</string>
|
||||
<!-- Introduction title shown in face enrollment education screen to show the face authentication feature, when face unlock is disabled by device admin [CHAR LIMIT=60] -->
|
||||
<string name="security_settings_face_enroll_education_title_accessibility">Set up face unlock</string>
|
||||
<!-- Introduction title shown in face enrollment education screen to show the face unlock feature, when face unlock is disabled by device admin [CHAR LIMIT=60] -->
|
||||
<string name="security_settings_face_enroll_education_title_unlock_disabled">Use your face to authenticate</string>
|
||||
<!-- Introduction detail message shown in face education [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_face_enroll_education_message"></string>
|
||||
@@ -910,7 +910,7 @@
|
||||
<string name="security_settings_face_enroll_introduction_cancel">Cancel</string>
|
||||
<!-- Introduction title shown in face enrollment to introduce the face unlock feature [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_face_enroll_introduction_title">Unlock with your face</string>
|
||||
<!-- Introduction title shown in face enrollment to introduce the face authentication feature, when face unlock is disabled by device admin [CHAR LIMIT=60] -->
|
||||
<!-- Introduction title shown in face enrollment to introduce the face unlock feature, when face unlock is disabled by device admin [CHAR LIMIT=60] -->
|
||||
<string name="security_settings_face_enroll_introduction_title_unlock_disabled">Use your face to authenticate</string>
|
||||
<!-- Introduction detail message shown in face enrollment dialog [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_face_enroll_introduction_message">Use your face to unlock your phone, authorize purchases, or sign in to apps.</string>
|
||||
@@ -952,13 +952,13 @@
|
||||
<string name="security_settings_face_settings_use_face_category">Use face unlock for</string>
|
||||
<!-- Text shown on a toggle which allows or disallows the device to use face for unlocking the device. [CHAR LIMIT=20] -->
|
||||
<string name="security_settings_face_settings_use_face_unlock_phone">Unlocking your phone</string>
|
||||
<!-- Text shown on a toggle which allows or disallows the device to use face authentication for apps. This will be presented to the user together with the context of security_settings_face_settings_use_face_category. [CHAR LIMIT=30] -->
|
||||
<!-- Text shown on a toggle which allows or disallows the device to use face unlock for apps. This will be presented to the user together with the context of security_settings_face_settings_use_face_category. [CHAR LIMIT=30] -->
|
||||
<string name="security_settings_face_settings_use_face_for_apps">App sign-in \u0026 payments</string>
|
||||
<!-- Title for a category shown for the face settings page, followed by items that the user can toggle on/off to require/disable. -->
|
||||
<string name="security_settings_face_settings_require_category">Require for face unlock</string>
|
||||
<!-- Text shown on a toggle which disables/enables face authentication, depending if the user's eyes are open. [CHAR LIMIT=30] -->
|
||||
<!-- Text shown on a toggle which disables/enables face unlock, depending if the user's eyes are open. [CHAR LIMIT=30] -->
|
||||
<string name="security_settings_face_settings_require_attention">Open eyes looking at screen</string>
|
||||
<!-- Text shown on the details of a toggle which disables/enables face authentication, depending if the user's eyes are open. [CHAR LIMIT=70] -->
|
||||
<!-- Text shown on the details of a toggle which disables/enables face unlock, depending if the user's eyes are open. [CHAR LIMIT=70] -->
|
||||
<string name="security_settings_face_settings_require_attention_details">To unlock the phone, always require looking at the screen with your eyes open</string>
|
||||
<!-- When authenticating in apps, always require confirmation (e.g. confirm button) after a face is authenticated. [CHAR LIMIT=50] -->
|
||||
<string name="security_settings_face_settings_require_confirmation">Confirm button</string>
|
||||
@@ -969,7 +969,7 @@
|
||||
<!-- Button text in face settings which lets the user enroll their face [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_face_settings_enroll">Set up new face unlock</string>
|
||||
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_face_settings_footer">Use Face unlock to unlock your device, sign in to apps, and confirm payments.\n\nKeep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face while your eyes are open.\n\nYour phone can be unlocked by someone who looks a lot like you, say, an identical sibling.</string>
|
||||
<string name="security_settings_face_settings_footer">Use face unlock to unlock your device, sign in to apps, and confirm payments.\n\nKeep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face while your eyes are open.\n\nYour phone can be unlocked by someone who looks a lot like you, say, an identical sibling.</string>
|
||||
<!-- Dialog title shown when the user removes an enrollment [CHAR LIMIT=35] -->
|
||||
<string name="security_settings_face_settings_remove_dialog_title">Delete face data?</string>
|
||||
<!-- Dialog contents shown when the user removes an enrollment [CHAR LIMIT=NONE] -->
|
||||
@@ -1074,12 +1074,12 @@
|
||||
<string name="fingerprint_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN, pattern, or password.</string>
|
||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (default) [CHAR LIMIT=NONE] -->
|
||||
<string name="fingerprint_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN, pattern, or password.</string>
|
||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (tablet) [CHAR LIMIT=NONE] -->
|
||||
<string name="face_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN, pattern, or password.</string>
|
||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (device) [CHAR LIMIT=NONE] -->
|
||||
<string name="face_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN, pattern, or password.</string>
|
||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (default) [CHAR LIMIT=NONE] -->
|
||||
<string name="face_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN, pattern, or password.</string>
|
||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face unlock. (tablet) [CHAR LIMIT=NONE] -->
|
||||
<string name="face_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face unlock. Tap Cancel, then set a PIN, pattern, or password.</string>
|
||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face unlock. (device) [CHAR LIMIT=NONE] -->
|
||||
<string name="face_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face unlock. Tap Cancel, then set a PIN, pattern, or password.</string>
|
||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face unlock. (default) [CHAR LIMIT=NONE] -->
|
||||
<string name="face_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face unlock. Tap Cancel, then set a PIN, pattern, or password.</string>
|
||||
<!-- Title of dialog shown when the user tries to skip setting up a PIN, warning them of potential consequences of not doing so [CHAR LIMIT=48]-->
|
||||
<string name="lock_screen_pin_skip_title">Skip PIN setup?</string>
|
||||
<!-- Title of dialog shown when the user tries to skip setting up a password, warning them of potential consequences of not doing so [CHAR LIMIT=48]-->
|
||||
@@ -1323,7 +1323,7 @@
|
||||
<!-- Message shown in screen lock picker while setting up the backup/fallback screen lock method for fingerprint. Users can choose to use this method to unlock the screen instead of fingerprint, or when fingerprint is not accepted. [CHAR LIMIT=80] [BACKUP_MESSAGE_ID=2799884038398627882] -->
|
||||
<string name="lock_settings_picker_fingerprint_message">Choose your backup screen lock method</string>
|
||||
|
||||
<!-- Message shown in screen lock picker while setting up the backup/fallbakc screen lock method for face authentication. Users can choose to use this method to unlock the screen instead of face authentication, or when face authentication is not accepted. [CHAR LIMIT=80] -->
|
||||
<!-- Message shown in screen lock picker while setting up the backup/fallback screen lock method for face unlock. Users can choose to use this method to unlock the screen instead of face unlock, or when face unlock is not accepted. [CHAR LIMIT=80] -->
|
||||
<string name="lock_settings_picker_face_message">Choose your backup screen lock method</string>
|
||||
|
||||
<!-- Label for button in screen lock settings, allowing users to choose other types of screen locks. [CHAR LIMIT=40] -->
|
||||
@@ -1401,19 +1401,19 @@
|
||||
<!-- Message shown in screen lock picker while setting up the new screen lock with fingerprint option. [CHAR LIMIT=NONE]-->
|
||||
<string name="fingerprint_unlock_title">You can unlock your phone using your fingerprint. For security, this option requires a backup screen lock.</string>
|
||||
|
||||
<!-- Title for preference that guides the user through creating a backup unlock pattern for face authentication [CHAR LIMIT=45]-->
|
||||
<string name="face_unlock_set_unlock_pattern">Face authentication + Pattern</string>
|
||||
<!-- Title for preference that guides the user through creating a backup unlock pattern for face unlock [CHAR LIMIT=45]-->
|
||||
<string name="face_unlock_set_unlock_pattern">Face unlock + Pattern</string>
|
||||
|
||||
<!-- Title for preference that guides the user through creating a backup unlock PIN for face authentication [CHAR LIMIT=45]-->
|
||||
<string name="face_unlock_set_unlock_pin">Face authentication + PIN</string>
|
||||
<!-- Title for preference that guides the user through creating a backup unlock PIN for face unlock [CHAR LIMIT=45]-->
|
||||
<string name="face_unlock_set_unlock_pin">Face unlock + PIN</string>
|
||||
|
||||
<!-- Title for preference that guides the user through creating a backup unlock password for face authentication [CHAR LIMIT=45]-->
|
||||
<string name="face_unlock_set_unlock_password">Face authentication + Password</string>
|
||||
<!-- Title for preference that guides the user through creating a backup unlock password for face unlock [CHAR LIMIT=45]-->
|
||||
<string name="face_unlock_set_unlock_password">Face unlock + Password</string>
|
||||
|
||||
<!-- Title for preference that guides the user to skip face authentication setup [CHAR LIMIT=60]-->
|
||||
<string name="face_unlock_skip_face">Continue without face authentication</string>
|
||||
<!-- Title for preference that guides the user to skip face unlock setup [CHAR LIMIT=60]-->
|
||||
<string name="face_unlock_skip_face">Continue without face unlock</string>
|
||||
|
||||
<!-- Message shown in screen lock picker while setting up the new screen lock with face authentication option. [CHAR LIMIT=NONE] -->
|
||||
<!-- Message shown in screen lock picker while setting up the new screen lock with face unlock option. [CHAR LIMIT=NONE] -->
|
||||
<string name="face_unlock_title">You can unlock your phone using your face. For security, this option requires a backup screen lock.</string>
|
||||
|
||||
<!-- Summary for preference that has been disabled by because of the DevicePolicyAdmin, or because device encryption is enabled, or because there are credentials in the credential storage [CHAR LIMIT=50] -->
|
||||
@@ -4049,12 +4049,12 @@
|
||||
<string name="lockpassword_pin_set_toast">PIN has been set</string>
|
||||
<!-- Toast shown if setting pattern was successful -->
|
||||
<string name="lockpassword_pattern_set_toast">Pattern has been set</string>
|
||||
<!-- Header on first screen of choose password/PIN as backup for face authentication flow. If this string cannot be translated in under 40 characters, please translate "Set face authentication backup" [CHAR LIMIT=40] -->
|
||||
<string name="lockpassword_choose_your_password_header_for_face">To use face authentication, set password</string>
|
||||
<!-- Header on first screen of choose pattern as backup for face authentication flow. If this string cannot be translated in under 40 characters, please translate "Set face authentication backup" [CHAR LIMIT=40] -->
|
||||
<string name="lockpassword_choose_your_pattern_header_for_face">To use face authentication, set pattern</string>
|
||||
<!-- Header on first screen of choose password/PIN as backup for face authentication flow. If this string cannot be translated in under 40 characters, please translate "Set face authentication backup" [CHAR LIMIT=40] -->
|
||||
<string name="lockpassword_choose_your_pin_header_for_face">To use face authentication, set PIN</string>
|
||||
<!-- Header on first screen of choose password/PIN as backup for face unlock flow. If this string cannot be translated in under 40 characters, please translate "Set face unlock backup" [CHAR LIMIT=40] -->
|
||||
<string name="lockpassword_choose_your_password_header_for_face">To use face unlock, set password</string>
|
||||
<!-- Header on first screen of choose pattern as backup for face unlock flow. If this string cannot be translated in under 40 characters, please translate "Set face unlock backup" [CHAR LIMIT=40] -->
|
||||
<string name="lockpassword_choose_your_pattern_header_for_face">To use face unlock, set pattern</string>
|
||||
<!-- Header on first screen of choose password/PIN as backup for face unlock flow. If this string cannot be translated in under 40 characters, please translate "Set face unlock backup" [CHAR LIMIT=40] -->
|
||||
<string name="lockpassword_choose_your_pin_header_for_face">To use face unlock, set PIN</string>
|
||||
|
||||
<!-- Message to be used to explain the user that he needs to enter his pattern to continue a
|
||||
particular operation. [CHAR LIMIT=70]-->
|
||||
@@ -10545,6 +10545,9 @@
|
||||
<!-- Help URI, USB Audio [DO NOT TRANSLATE] -->
|
||||
<string name="help_url_audio_accessory_not_supported" translatable="false"></string>
|
||||
|
||||
<!-- Help URI, USB Contaminant [DO NOT TRANSLATE] -->
|
||||
<string name="help_url_usb_contaminant_detected" translatable="false"></string>
|
||||
|
||||
<!-- Help URI, restricted apps page [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_restricted_apps" translatable="false"></string>
|
||||
|
||||
|
||||
@@ -1,289 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Telephony.Sms.Intents;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.app.AlertActivity;
|
||||
import com.android.internal.app.AlertController;
|
||||
import com.android.internal.telephony.SmsApplication;
|
||||
import com.android.internal.telephony.SmsApplication.SmsApplicationData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class SmsDefaultDialog extends AlertActivity implements
|
||||
DialogInterface.OnClickListener {
|
||||
private SmsApplicationData mNewSmsApplicationData;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent intent = getIntent();
|
||||
String packageName = intent.getStringExtra(Intents.EXTRA_PACKAGE_NAME);
|
||||
|
||||
setResult(RESULT_CANCELED);
|
||||
if (!buildDialog(packageName)) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
android.util.EventLog.writeEvent(0x534e4554, "120484087", -1, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
final Window window = getWindow();
|
||||
final WindowManager.LayoutParams attrs = window.getAttributes();
|
||||
attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
window.setAttributes(attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case BUTTON_POSITIVE:
|
||||
SmsApplication.setDefaultApplication(mNewSmsApplicationData.mPackageName, this);
|
||||
setResult(RESULT_OK);
|
||||
break;
|
||||
case BUTTON_NEGATIVE:
|
||||
break;
|
||||
default:
|
||||
if (which >= 0) {
|
||||
AppListAdapter adapter = (AppListAdapter) mAlertParams.mAdapter;
|
||||
if (!adapter.isSelected(which)) {
|
||||
String packageName = adapter.getPackageName(which);
|
||||
if (!TextUtils.isEmpty(packageName)) {
|
||||
SmsApplication.setDefaultApplication(packageName, this);
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean buildDialog(String packageName) {
|
||||
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if (!tm.isSmsCapable()) {
|
||||
// No phone, no SMS
|
||||
return false;
|
||||
}
|
||||
final AlertController.AlertParams p = mAlertParams;
|
||||
p.mTitle = getString(R.string.sms_change_default_dialog_title);
|
||||
mNewSmsApplicationData = SmsApplication.getSmsApplicationData(packageName, this);
|
||||
if (mNewSmsApplicationData != null) {
|
||||
// New default SMS app specified, change to that directly after the confirmation
|
||||
// dialog.
|
||||
SmsApplicationData oldSmsApplicationData = null;
|
||||
ComponentName oldSmsComponent = SmsApplication.getDefaultSmsApplication(this, true);
|
||||
if (oldSmsComponent != null) {
|
||||
oldSmsApplicationData = SmsApplication.getSmsApplicationData(
|
||||
oldSmsComponent.getPackageName(), this);
|
||||
if (oldSmsApplicationData.mPackageName.equals(
|
||||
mNewSmsApplicationData.mPackageName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Compose dialog; get
|
||||
if (oldSmsApplicationData != null) {
|
||||
p.mMessage = getString(R.string.sms_change_default_dialog_text,
|
||||
mNewSmsApplicationData.getApplicationName(this),
|
||||
oldSmsApplicationData.getApplicationName(this));
|
||||
} else {
|
||||
p.mMessage = getString(R.string.sms_change_default_no_previous_dialog_text,
|
||||
mNewSmsApplicationData.getApplicationName(this));
|
||||
}
|
||||
p.mPositiveButtonText = getString(R.string.yes);
|
||||
p.mNegativeButtonText = getString(R.string.no);
|
||||
p.mPositiveButtonListener = this;
|
||||
p.mNegativeButtonListener = this;
|
||||
} else {
|
||||
// No new default SMS app specified, show a list of all SMS apps and let user to pick
|
||||
p.mAdapter = new AppListAdapter();
|
||||
p.mOnClickListener = this;
|
||||
p.mNegativeButtonText = getString(R.string.cancel);
|
||||
p.mNegativeButtonListener = this;
|
||||
if (p.mAdapter.isEmpty()) {
|
||||
// If there is nothing to choose from, don't build the dialog.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
setupAlert();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of SMS apps with label, icon. Current default SMS app is marked as "default".
|
||||
*/
|
||||
private class AppListAdapter extends BaseAdapter {
|
||||
/**
|
||||
* SMS app item in the list
|
||||
*/
|
||||
private class Item {
|
||||
final String label; // app label
|
||||
final Drawable icon; // app icon
|
||||
final String packgeName; // full app package name
|
||||
|
||||
public Item(String label, Drawable icon, String packageName) {
|
||||
this.label = label;
|
||||
this.icon = icon;
|
||||
this.packgeName = packageName;
|
||||
}
|
||||
}
|
||||
|
||||
// The list
|
||||
private final List<Item> mItems;
|
||||
// The index of selected
|
||||
private final int mSelectedIndex;
|
||||
|
||||
public AppListAdapter() {
|
||||
mItems = getItems();
|
||||
int selected = getSelectedIndex();
|
||||
// Move selected up to the top so it is easy to find
|
||||
if (selected > 0) {
|
||||
Item item = mItems.remove(selected);
|
||||
mItems.add(0, item);
|
||||
selected = 0;
|
||||
}
|
||||
mSelectedIndex = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mItems != null ? mItems.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mItems != null && position < mItems.size() ? mItems.get(position) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Item item = ((Item) getItem(position));
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.app_preference_item, parent, false);
|
||||
TextView textView = (TextView) view.findViewById(android.R.id.title);
|
||||
textView.setText(item.label);
|
||||
if (position == mSelectedIndex) {
|
||||
view.findViewById(R.id.default_label).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.findViewById(R.id.default_label).setVisibility(View.GONE);
|
||||
}
|
||||
ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
|
||||
imageView.setImageDrawable(item.icon);
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the selected package name by
|
||||
*
|
||||
* @param position the index of the item in the list
|
||||
* @return the package name of selected item
|
||||
*/
|
||||
public String getPackageName(int position) {
|
||||
Item item = (Item) getItem(position);
|
||||
if (item != null) {
|
||||
return item.packgeName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an item at a position is already selected
|
||||
*
|
||||
* @param position the index of the item in the list
|
||||
* @return true if the item at the position is already selected, false otherwise
|
||||
*/
|
||||
public boolean isSelected(int position) {
|
||||
return position == mSelectedIndex;
|
||||
}
|
||||
|
||||
// Get the list items by looking for SMS apps
|
||||
private List<Item> getItems() {
|
||||
PackageManager pm = getPackageManager();
|
||||
List<Item> items = new ArrayList<>();
|
||||
for (SmsApplication.SmsApplicationData app :
|
||||
SmsApplication.getApplicationCollection(SmsDefaultDialog.this)) {
|
||||
try {
|
||||
String packageName = app.mPackageName;
|
||||
ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0/*flags*/);
|
||||
if (appInfo != null) {
|
||||
items.add(new Item(
|
||||
appInfo.loadLabel(pm).toString(),
|
||||
appInfo.loadIcon(pm),
|
||||
packageName));
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// Ignore package can't be found
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
// Get the selected item index by looking for the current default SMS app
|
||||
private int getSelectedIndex() {
|
||||
ComponentName appName = SmsApplication.getDefaultSmsApplication(
|
||||
SmsDefaultDialog.this, true);
|
||||
if (appName != null) {
|
||||
String defaultSmsAppPackageName = appName.getPackageName();
|
||||
if (!TextUtils.isEmpty(defaultSmsAppPackageName)) {
|
||||
for (int i = 0; i < mItems.size(); i++) {
|
||||
if (TextUtils.equals(mItems.get(i).packgeName, defaultSmsAppPackageName)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,8 +198,8 @@ public class OverlayCategoryPreferenceController extends DeveloperOptionsPrefere
|
||||
@Override
|
||||
protected void onDeveloperOptionsSwitchDisabled() {
|
||||
super.onDeveloperOptionsSwitchDisabled();
|
||||
// STOPSHIP b/122308197: reset the overlays to the set in
|
||||
// Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES
|
||||
// TODO b/133222035: remove these developer settings when the
|
||||
// Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES setting is used
|
||||
setOverlay(PACKAGE_DEVICE_DEFAULT);
|
||||
updateState(mPreference);
|
||||
}
|
||||
|
||||
@@ -297,6 +297,9 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
||||
}
|
||||
|
||||
private void updateSignalStrength(SignalStrength signalStrength) {
|
||||
if (signalStrength == null) {
|
||||
return;
|
||||
}
|
||||
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
|
||||
final PersistableBundle carrierConfig =
|
||||
mCarrierConfigManager.getConfigForSubId(subscriptionId);
|
||||
@@ -430,13 +433,11 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
||||
mSubscriptionInfo.getSubscriptionId());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getDbm(SignalStrength signalStrength) {
|
||||
private int getDbm(SignalStrength signalStrength) {
|
||||
return signalStrength.getDbm();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getAsuLevel(SignalStrength signalStrength) {
|
||||
private int getAsuLevel(SignalStrength signalStrength) {
|
||||
return signalStrength.getAsuLevel();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.view.Gravity;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.graph.SignalDrawable;
|
||||
|
||||
import java.util.List;
|
||||
@@ -144,6 +145,7 @@ public class NetworkOperatorPreference extends Preference {
|
||||
// Set the signal strength icon at the bottom right
|
||||
icons.setLayerGravity(1 /* index of SignalDrawable */, Gravity.BOTTOM | Gravity.RIGHT);
|
||||
icons.setLayerSize(1 /* index of SignalDrawable */, iconSize, iconSize);
|
||||
icons.setTintList(Utils.getColorAttr(context, android.R.attr.colorControlNormal));
|
||||
setIcon(icons);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,9 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
|
||||
return false;
|
||||
}
|
||||
if (mChannelGroup != null) {
|
||||
return !mChannelGroup.isBlocked();
|
||||
if (mChannelGroup.isBlocked()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (mChannel != null) {
|
||||
return mChannel.getImportance() != IMPORTANCE_NONE;
|
||||
|
||||
@@ -25,6 +25,7 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
|
||||
|
||||
import static com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment.RESULT_FINISHED;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
@@ -169,6 +170,12 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
/** From intent extra {@link ChooseLockSettingsHelper#EXTRA_KEY_CALLER_APP_NAME}. */
|
||||
private String mCallerAppName = null;
|
||||
|
||||
/**
|
||||
* The value from the intent extra {@link
|
||||
* ChooseLockSettingsHelper#EXTRA_KEY_IS_CALLING_APP_ADMIN}.
|
||||
*/
|
||||
private boolean mIsCallingAppAdmin;
|
||||
|
||||
protected boolean mForFingerprint = false;
|
||||
protected boolean mForFace = false;
|
||||
|
||||
@@ -217,6 +224,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
.getIntExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_NONE);
|
||||
mCallerAppName =
|
||||
getActivity().getIntent().getStringExtra(EXTRA_KEY_CALLER_APP_NAME);
|
||||
mIsCallingAppAdmin = getActivity().getIntent()
|
||||
.getBooleanExtra(EXTRA_KEY_IS_CALLING_APP_ADMIN, /* defValue= */ false);
|
||||
mForChangeCredRequiredForBoot = getArguments() != null && getArguments().getBoolean(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT);
|
||||
mUserManager = UserManager.get(getActivity());
|
||||
@@ -490,7 +499,7 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
protected void addPreferences() {
|
||||
addPreferencesFromResource(R.xml.security_settings_picker);
|
||||
|
||||
if (!TextUtils.isEmpty(mCallerAppName)) {
|
||||
if (!TextUtils.isEmpty(mCallerAppName) && !mIsCallingAppAdmin) {
|
||||
FooterPreferenceMixinCompat footerMixin =
|
||||
new FooterPreferenceMixinCompat(this, getSettingsLifecycle());
|
||||
FooterPreference footer = footerMixin.createFooterPreference();
|
||||
|
||||
@@ -60,6 +60,12 @@ public final class ChooseLockSettingsHelper {
|
||||
*/
|
||||
public static final String EXTRA_KEY_CALLER_APP_NAME = "caller_app_name";
|
||||
|
||||
/**
|
||||
* Intent extra indicating that the calling app is an admin, such as a Device Adimn, Device
|
||||
* Owner, or Profile Owner.
|
||||
*/
|
||||
public static final String EXTRA_KEY_IS_CALLING_APP_ADMIN = "is_calling_app_admin";
|
||||
|
||||
/**
|
||||
* When invoked via {@link ConfirmLockPassword.InternalActivity}, this flag
|
||||
* controls if we relax the enforcement of
|
||||
|
||||
@@ -23,6 +23,7 @@ import static android.app.admin.DevicePolicyManager.EXTRA_PASSWORD_COMPLEXITY;
|
||||
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
|
||||
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -30,6 +31,8 @@ import android.app.admin.DevicePolicyManager;
|
||||
import android.app.admin.DevicePolicyManager.PasswordComplexity;
|
||||
import android.app.admin.PasswordMetrics;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
@@ -39,6 +42,8 @@ import com.android.settings.Utils;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Trampolines {@link DevicePolicyManager#ACTION_SET_NEW_PASSWORD} and
|
||||
* {@link DevicePolicyManager#ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} intent to the appropriate UI
|
||||
@@ -116,10 +121,28 @@ public class SetNewPasswordActivity extends Activity implements SetNewPasswordCo
|
||||
if (mRequestedMinComplexity != PASSWORD_COMPLEXITY_NONE) {
|
||||
intent.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, mRequestedMinComplexity);
|
||||
}
|
||||
if (isCallingAppAdmin()) {
|
||||
intent.putExtra(EXTRA_KEY_IS_CALLING_APP_ADMIN, true);
|
||||
}
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
private boolean isCallingAppAdmin() {
|
||||
DevicePolicyManager devicePolicyManager = getSystemService(DevicePolicyManager.class);
|
||||
String callingAppPackageName = PasswordUtils.getCallingAppPackageName(getActivityToken());
|
||||
List<ComponentName> admins = devicePolicyManager.getActiveAdmins();
|
||||
if (admins == null) {
|
||||
return false;
|
||||
}
|
||||
for (ComponentName componentName : admins) {
|
||||
if (componentName.getPackageName().equals(callingAppPackageName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void logSetNewPasswordIntent() {
|
||||
final String callingAppPackageName =
|
||||
PasswordUtils.getCallingAppPackageName(getActivityToken());
|
||||
|
||||
@@ -69,6 +69,13 @@ public class SeekBarPreference extends RestrictedPreference
|
||||
com.android.internal.R.layout.preference_widget_seekbar);
|
||||
a.recycle();
|
||||
|
||||
a = context.obtainStyledAttributes(
|
||||
attrs, com.android.internal.R.styleable.Preference, defStyleAttr, defStyleRes);
|
||||
final boolean isSelectable = a.getBoolean(
|
||||
com.android.settings.R.styleable.Preference_android_selectable, false);
|
||||
setSelectable(isSelectable);
|
||||
a.recycle();
|
||||
|
||||
setLayoutResource(layoutResId);
|
||||
}
|
||||
|
||||
@@ -93,7 +100,11 @@ public class SeekBarPreference extends RestrictedPreference
|
||||
|
||||
@Override
|
||||
public boolean isSelectable() {
|
||||
return isDisabledByAdmin();
|
||||
if(isDisabledByAdmin()) {
|
||||
return true;
|
||||
} else {
|
||||
return super.isSelectable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
23
tests/robotests/res/xml-mcc998/seekbar_preference.xml
Normal file
23
tests/robotests/res/xml-mcc998/seekbar_preference.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2019 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<com.android.settings.widget.SeekBarPreference
|
||||
android:key="seek_bar"
|
||||
android:title="seek_bar_title"/>
|
||||
</PreferenceScreen >
|
||||
24
tests/robotests/res/xml-mcc999/seekbar_preference.xml
Normal file
24
tests/robotests/res/xml-mcc999/seekbar_preference.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2019 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<com.android.settings.widget.SeekBarPreference
|
||||
android:key="seek_bar"
|
||||
android:selectable="true"
|
||||
android:title="seek_bar_title"/>
|
||||
</PreferenceScreen >
|
||||
@@ -121,8 +121,8 @@ public class SimStatusDialogControllerTest {
|
||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||
mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0 /* phone id */));
|
||||
doReturn(mServiceState).when(mController).getCurrentServiceState();
|
||||
doReturn(0).when(mController).getDbm(any());
|
||||
doReturn(0).when(mController).getAsuLevel(any());
|
||||
doReturn(0).when(mSignalStrength).getDbm();
|
||||
doReturn(0).when(mSignalStrength).getAsuLevel();
|
||||
doReturn(mPhoneStateListener).when(mController).getPhoneStateListener();
|
||||
doReturn("").when(mController).getPhoneNumber();
|
||||
doReturn(mSignalStrength).when(mController).getSignalStrength();
|
||||
@@ -136,6 +136,9 @@ public class SimStatusDialogControllerTest {
|
||||
ReflectionHelpers.setField(mController, "mEuiccManager", mEuiccManager);
|
||||
ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager);
|
||||
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mPersistableBundle);
|
||||
when(mPersistableBundle.getBoolean(
|
||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
|
||||
.thenReturn(true);
|
||||
|
||||
final ShadowPackageManager shadowPackageManager =
|
||||
Shadows.shadowOf(RuntimeEnvironment.application.getPackageManager());
|
||||
@@ -228,8 +231,8 @@ public class SimStatusDialogControllerTest {
|
||||
public void initialize_updateSignalStrengthWith50_shouldUpdateSignalStrengthTo50() {
|
||||
final int signalDbm = 50;
|
||||
final int signalAsu = 50;
|
||||
doReturn(signalDbm).when(mController).getDbm(mSignalStrength);
|
||||
doReturn(signalAsu).when(mController).getAsuLevel(mSignalStrength);
|
||||
doReturn(signalDbm).when(mSignalStrength).getDbm();
|
||||
doReturn(signalAsu).when(mSignalStrength).getAsuLevel();
|
||||
when(mPersistableBundle.getBoolean(
|
||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
||||
|
||||
@@ -249,8 +252,8 @@ public class SimStatusDialogControllerTest {
|
||||
|
||||
final int signalDbm = 50;
|
||||
final int signalAsu = 50;
|
||||
doReturn(signalDbm).when(mController).getDbm(mSignalStrength);
|
||||
doReturn(signalAsu).when(mController).getAsuLevel(mSignalStrength);
|
||||
doReturn(signalDbm).when(mSignalStrength).getDbm();
|
||||
doReturn(signalAsu).when(mSignalStrength).getAsuLevel();
|
||||
when(mPersistableBundle.getBoolean(
|
||||
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
|
||||
|
||||
@@ -415,4 +418,11 @@ public class SimStatusDialogControllerTest {
|
||||
verify(mDialog).removeSettingFromScreen(IMS_REGISTRATION_STATE_LABEL_ID);
|
||||
verify(mDialog).removeSettingFromScreen(IMS_REGISTRATION_STATE_VALUE_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_nullSignalStrength_noCrash() {
|
||||
doReturn(null).when(mController).getSignalStrength();
|
||||
// we should not crash when running the following line
|
||||
mController.initialize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,10 +105,12 @@ public class NotificationPreferenceControllerTest {
|
||||
@Test
|
||||
public void isAvailable_notIfChannelBlocked() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
|
||||
when(group.isBlocked()).thenReturn(false);
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
|
||||
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
mController.onResume(appRow, channel, group, null);
|
||||
assertFalse(mController.isAvailable());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_MEDIUM;
|
||||
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
|
||||
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -182,12 +183,22 @@ public class ChooseLockGenericTest {
|
||||
CharSequence expectedTitle =
|
||||
mActivity.getString(R.string.unlock_footer_none_complexity_requested, "app name");
|
||||
|
||||
mFragment.updatePreferencesOrFinish(false /* isRecreatingActivity */);
|
||||
mFragment.updatePreferencesOrFinish(/* isRecreatingActivity= */ false);
|
||||
FooterPreference footer = mFragment.findPreference(FooterPreference.KEY_FOOTER);
|
||||
|
||||
assertThat(footer.getTitle()).isEqualTo(expectedTitle);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreferencesOrFinish_callingAppIsAdmin_noFooter() {
|
||||
initActivity(new Intent().putExtra(EXTRA_KEY_IS_CALLING_APP_ADMIN, true));
|
||||
|
||||
mFragment.updatePreferencesOrFinish(/* isRecreatingActivity= */ false);
|
||||
|
||||
FooterPreference footer = mFragment.findPreference(FooterPreference.KEY_FOOTER);
|
||||
assertThat(footer).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onActivityResult_requestcode0_shouldNotFinish() {
|
||||
initActivity(null);
|
||||
|
||||
@@ -24,6 +24,7 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_HIGH;
|
||||
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
|
||||
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -32,8 +33,10 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
@@ -54,6 +57,8 @@ import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.Shadows;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowActivity;
|
||||
import org.robolectric.shadows.ShadowDevicePolicyManager;
|
||||
import org.robolectric.shadows.ShadowLog;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class SetNewPasswordActivityTest {
|
||||
@@ -91,7 +96,7 @@ public class SetNewPasswordActivityTest {
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class).get();
|
||||
activity.launchChooseLock(new Bundle());
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||
Intent intent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
Intent intent = getLaunchChooseLockIntent(shadowActivity);
|
||||
|
||||
assertThat(intent.getComponent())
|
||||
.isEqualTo(new ComponentName(activity, ChooseLockGeneric.class));
|
||||
@@ -105,7 +110,7 @@ public class SetNewPasswordActivityTest {
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class).get();
|
||||
activity.launchChooseLock(new Bundle());
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||
Intent intent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
Intent intent = getLaunchChooseLockIntent(shadowActivity);
|
||||
|
||||
assertThat(intent.getComponent())
|
||||
.isEqualTo(new ComponentName(activity, SetupChooseLockGeneric.class));
|
||||
@@ -149,7 +154,7 @@ public class SetNewPasswordActivityTest {
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class, intent).create().get();
|
||||
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||
Intent actualIntent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
Intent actualIntent = getLaunchChooseLockIntent(shadowActivity);
|
||||
assertThat(actualIntent.getAction()).isEqualTo(ACTION_SET_NEW_PASSWORD);
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)).isTrue();
|
||||
assertThat(actualIntent.getIntExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_NONE))
|
||||
@@ -179,7 +184,7 @@ public class SetNewPasswordActivityTest {
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class, intent).create().get();
|
||||
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||
Intent actualIntent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
Intent actualIntent = getLaunchChooseLockIntent(shadowActivity);
|
||||
assertThat(actualIntent.getAction()).isEqualTo(ACTION_SET_NEW_PASSWORD);
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)).isFalse();
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_CALLER_APP_NAME)).isTrue();
|
||||
@@ -207,7 +212,7 @@ public class SetNewPasswordActivityTest {
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class, intent).create().get();
|
||||
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||
Intent actualIntent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
Intent actualIntent = getLaunchChooseLockIntent(shadowActivity);
|
||||
assertThat(actualIntent.getAction()).isEqualTo(ACTION_SET_NEW_PASSWORD);
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)).isFalse();
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_CALLER_APP_NAME)).isTrue();
|
||||
@@ -234,7 +239,7 @@ public class SetNewPasswordActivityTest {
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class, intent).create().get();
|
||||
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||
Intent actualIntent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
Intent actualIntent = getLaunchChooseLockIntent(shadowActivity);
|
||||
assertThat(actualIntent.getAction()).isEqualTo(ACTION_SET_NEW_PASSWORD);
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)).isFalse();
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_CALLER_APP_NAME)).isTrue();
|
||||
@@ -262,7 +267,7 @@ public class SetNewPasswordActivityTest {
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class, intent).create().get();
|
||||
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||
Intent actualIntent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
Intent actualIntent = getLaunchChooseLockIntent(shadowActivity);
|
||||
assertThat(actualIntent.getAction()).isEqualTo(ACTION_SET_NEW_PARENT_PROFILE_PASSWORD);
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)).isFalse();
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_CALLER_APP_NAME)).isTrue();
|
||||
@@ -289,7 +294,7 @@ public class SetNewPasswordActivityTest {
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class, intent).create().get();
|
||||
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||
Intent actualIntent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
Intent actualIntent = getLaunchChooseLockIntent(shadowActivity);
|
||||
assertThat(actualIntent.getAction()).isEqualTo(ACTION_SET_NEW_PARENT_PROFILE_PASSWORD);
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)).isFalse();
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_CALLER_APP_NAME)).isTrue();
|
||||
@@ -301,4 +306,45 @@ public class SetNewPasswordActivityTest {
|
||||
PKG_NAME,
|
||||
Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowPasswordUtils.class})
|
||||
public void launchChooseLock_callingAppIsAdmin_setsAdminExtra() {
|
||||
SetNewPasswordActivity activity =
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class).get();
|
||||
DevicePolicyManager devicePolicyManager =
|
||||
(DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
Shadows.shadowOf(devicePolicyManager).setActiveAdmin(buildTestComponentName(PKG_NAME));
|
||||
ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
|
||||
|
||||
activity.launchChooseLock(new Bundle());
|
||||
|
||||
Intent intent = getLaunchChooseLockIntent(Shadows.shadowOf(activity));
|
||||
assertThat(intent.hasExtra(EXTRA_KEY_IS_CALLING_APP_ADMIN)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowPasswordUtils.class})
|
||||
public void launchChooseLock_callingAppIsNotAdmin_doesNotSetAdminExtra() {
|
||||
SetNewPasswordActivity activity =
|
||||
Robolectric.buildActivity(SetNewPasswordActivity.class).get();
|
||||
DevicePolicyManager devicePolicyManager =
|
||||
(DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
Shadows.shadowOf(devicePolicyManager)
|
||||
.setActiveAdmin(buildTestComponentName("other_pkg_name"));
|
||||
ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
|
||||
|
||||
activity.launchChooseLock(new Bundle());
|
||||
|
||||
Intent intent = getLaunchChooseLockIntent(Shadows.shadowOf(activity));
|
||||
assertThat(intent.hasExtra(EXTRA_KEY_IS_CALLING_APP_ADMIN)).isFalse();
|
||||
}
|
||||
|
||||
private ComponentName buildTestComponentName(String packageName) {
|
||||
return new ComponentName(packageName, "clazz");
|
||||
}
|
||||
|
||||
private Intent getLaunchChooseLockIntent(ShadowActivity shadowActivity) {
|
||||
return shadowActivity.getNextStartedActivityForResult().intent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,16 +22,24 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.androidx.fragment.FragmentController;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowRestrictedLockUtilsInternal.class)
|
||||
public class SeekBarPreferenceTest {
|
||||
|
||||
private static final int MAX = 75;
|
||||
@@ -73,9 +81,39 @@ public class SeekBarPreferenceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSelectable_notDisabledByAdmin_returnFalse() {
|
||||
when(mSeekBarPreference.isDisabledByAdmin()).thenReturn(false);
|
||||
@Config(qualifiers = "mcc998")
|
||||
public void isSelectable_default_returnFalse() {
|
||||
final PreferenceFragmentCompat fragment = FragmentController.of(new TestFragment(),
|
||||
new Bundle())
|
||||
.create()
|
||||
.start()
|
||||
.resume()
|
||||
.get();
|
||||
|
||||
assertThat(mSeekBarPreference.isSelectable()).isFalse();
|
||||
final SeekBarPreference seekBarPreference = fragment.findPreference("seek_bar");
|
||||
|
||||
assertThat(seekBarPreference.isSelectable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void isSelectable_selectableInXml_returnTrue() {
|
||||
final PreferenceFragmentCompat fragment = FragmentController.of(new TestFragment(),
|
||||
new Bundle())
|
||||
.create()
|
||||
.start()
|
||||
.resume()
|
||||
.get();
|
||||
|
||||
final SeekBarPreference seekBarPreference = fragment.findPreference("seek_bar");
|
||||
|
||||
assertThat(seekBarPreference.isSelectable()).isTrue();
|
||||
}
|
||||
|
||||
public static class TestFragment extends PreferenceFragmentCompat {
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(com.android.settings.R.xml.seekbar_preference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user