• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Settings


Commit MetaInfo

Revisioncaca20d4eb172986c350a13dac4f2f9e9b94a9a0 (tree)
Zeit2021-07-01 20:04:01
AutorAndroid Build Coastguard Worker <android-build-coastguard-worker@goog...>
CommiterAndroid Build Coastguard Worker

Log Message

Merge cherrypicks of [15172584, 15172286, 15172594, 15172385, 15172631, 15172632, 15172633, 15172634, 15171221, 15171222, 15171223, 15171541, 15171542, 15171668, 15172342, 15170823, 15170824, 15170825, 15170826, 15170827, 15170828, 15170829, 15172650, 15172651, 15172652, 15172653, 15172654, 15172655, 15172656, 15172657, 15172658, 15172659, 15172660, 15172661, 15172386, 15172387, 15172388, 15172389, 15172670, 15172553, 15172589, 15172343, 15172617, 15172618, 15172619, 15172620, 15172690, 15172691, 15172692, 15172693, 15172694, 15172695, 15172696, 15172697, 15171708, 15171709, 15172554, 15172555, 15172710, 15172621, 15172635, 15172636, 15172698, 15172699, 15172700, 15171543, 15172701, 15172702, 15172703, 15172704, 15171669, 15172622] into rvc-d2-release

Change-Id: Ic3c06db90ac9c1a0656cc3d3b225dcc6a0787150

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/res/values-mcc234/strings.xml
@@ -0,0 +1,18 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<!-- Copyright (C) 2021 The Android Open Source Project
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+-->
16+<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
17+ <string name="cell_broadcast_settings">Emergency alerts</string>
18+</resources>
\ No newline at end of file
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -12198,15 +12198,39 @@
1219812198 <string name="aware_summary_when_bedtime_on">Unavailable because bedtime mode is on</string>
1219912199
1220012200 <!-- Bluetooth message permission alert for notification content [CHAR LIMIT=none] -->
12201- <string name="bluetooth_message_access_notification_content">Untrusted device wants to access your messages. Tap for details.</string>
12201+ <string name="bluetooth_message_access_notification_content">A device wants to access your messages. Tap for details.</string>
1220212202 <!-- Bluetooth message permission alert for dialog title [CHAR LIMIT=none] -->
1220312203 <string name="bluetooth_message_access_dialog_title">Allow access to messages?</string>
1220412204 <!-- Bluetooth message permission alert for dialog content [CHAR LIMIT=none] -->
12205- <string name="bluetooth_message_access_dialog_content">An untrusted Bluetooth device, <xliff:g id="device_name" example="My device">%1$s</xliff:g>, wants to access your messages.\n\nYou haven\u2019t connected to <xliff:g id="device_name" example="My device">%2$s</xliff:g> before.</string>
12205+ <string name="bluetooth_message_access_dialog_content">A Bluetooth device, <xliff:g id="device_name" example="My device">%1$s</xliff:g>, wants to access your messages.\n\nYou haven\u2019t connected to <xliff:g id="device_name" example="My device">%2$s</xliff:g> before.</string>
1220612206 <!-- Bluetooth phonebook permission alert for notification content [CHAR LIMIT=none] -->
12207- <string name="bluetooth_phonebook_access_notification_content">Untrusted device wants to access your contacts and call log. Tap for details.</string>
12207+ <string name="bluetooth_phonebook_access_notification_content">A device wants to access your contacts and call log. Tap for details.</string>
1220812208 <!-- Bluetooth phonebook permission alert for dialog title [CHAR LIMIT=none] -->
1220912209 <string name="bluetooth_phonebook_access_dialog_title">Allow access to contacts and call log?</string>
1221012210 <!-- Bluetooth phonebook permission alert for dialog content [CHAR LIMIT=none] -->
12211- <string name="bluetooth_phonebook_access_dialog_content">An untrusted Bluetooth device, <xliff:g id="device_name" example="My device">%1$s</xliff:g>, wants to access your contacts and call log. This includes data about incoming and outgoing calls.\n\nYou haven\u2019t connected to <xliff:g id="device_name" example="My device">%2$s</xliff:g> before.</string>
12211+ <string name="bluetooth_phonebook_access_dialog_content">A Bluetooth device, <xliff:g id="device_name" example="My device">%1$s</xliff:g>, wants to access your contacts and call log. This includes data about incoming and outgoing calls.\n\nYou haven\u2019t connected to <xliff:g id="device_name" example="My device">%2$s</xliff:g> before.</string>
12212+
12213+ <!-- Label for button to not allow grant the permission for remote devices. [CHAR_LIMIT=50] -->
12214+ <string name="request_manage_bluetooth_permission_dont_allow">Don\u2019t allow</string>
12215+
12216+ <!-- Bluetooth sim card permission alert for notification title [CHAR LIMIT=none] -->
12217+ <string name="bluetooth_sim_card_access_notification_title">SIM card access request</string>
12218+ <!-- Bluetooth sim card permission alert for notification content [CHAR LIMIT=none] -->
12219+ <string name="bluetooth_sim_card_access_notification_content">A device wants to access your SIM card. Tap for details.</string>
12220+ <!-- Bluetooth sim card permission alert for dialog title [CHAR LIMIT=none] -->
12221+ <string name="bluetooth_sim_card_access_dialog_title">Allow access to SIM card?</string>
12222+ <!-- Bluetooth sim card permission alert for dialog content [CHAR LIMIT=none] -->
12223+ <string name="bluetooth_sim_card_access_dialog_content">A Bluetooth device, <xliff:g id="device_name" example="My device">%1$s</xliff:g>, wants to access data on your SIM card. This includes your contacts.\n\nWhile connected, <xliff:g id="device_name" example="My device">%2$s</xliff:g> will receive all calls made to <xliff:g id="phone_number" example="0912345678">%3$s</xliff:g>.</string>
12224+ <!-- Bluetooth connect permission alert for notification title [CHAR LIMIT=none] -->
12225+ <string name="bluetooth_connect_access_notification_title">Bluetooth device available</string>
12226+ <!-- Bluetooth connect permission alert for notification content [CHAR LIMIT=none] -->
12227+ <string name="bluetooth_connect_access_notification_content">A device wants to connect. Tap for details.</string>
12228+ <!-- Bluetooth connect permission alert for dialog title [CHAR LIMIT=none] -->
12229+ <string name="bluetooth_connect_access_dialog_title">Connect to Bluetooth device?</string>
12230+ <!-- Bluetooth connect permission alert for dialog content [CHAR LIMIT=none] -->
12231+ <string name="bluetooth_connect_access_dialog_content"><xliff:g id="device_name" example="My device">%1$s</xliff:g> wants to connect to this phone.\n\nYou haven\u2019t connected to <xliff:g id="device_name" example="My device">%2$s</xliff:g> before.</string>
12232+ <!-- Strings for Dialog don't connect button -->
12233+ <string name="bluetooth_connect_access_dialog_negative">Don\u2019t connect</string>
12234+ <!-- Strings for Dialog connect button -->
12235+ <string name="bluetooth_connect_access_dialog_positive">Connect</string>
1221212236 </resources>
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
@@ -102,7 +102,7 @@ public class DeviceAdminAdd extends Activity {
102102 DevicePolicyManager mDPM;
103103 AppOpsManager mAppOps;
104104 DeviceAdminInfo mDeviceAdmin;
105- CharSequence mAddMsgText;
105+ String mAddMsgText;
106106 String mProfileOwnerName;
107107
108108 ImageView mAdminIcon;
@@ -274,7 +274,11 @@ public class DeviceAdminAdd extends Activity {
274274 }
275275 }
276276
277- mAddMsgText = getIntent().getCharSequenceExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION);
277+ final CharSequence addMsgCharSequence = getIntent().getCharSequenceExtra(
278+ DevicePolicyManager.EXTRA_ADD_EXPLANATION);
279+ if (addMsgCharSequence != null) {
280+ mAddMsgText = addMsgCharSequence.toString();
281+ }
278282
279283 if (mAddingProfileOwner) {
280284 // If we're trying to add a profile owner and user setup hasn't completed yet, no
@@ -628,7 +632,7 @@ public class DeviceAdminAdd extends Activity {
628632 } catch (Resources.NotFoundException e) {
629633 mAdminDescription.setVisibility(View.GONE);
630634 }
631- if (mAddMsgText != null) {
635+ if (!TextUtils.isEmpty(mAddMsgText)) {
632636 mAddMsg.setText(mAddMsgText);
633637 mAddMsg.setVisibility(View.VISIBLE);
634638 } else {
--- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
@@ -16,6 +16,8 @@
1616
1717 package com.android.settings.bluetooth;
1818
19+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
20+
1921 import android.bluetooth.BluetoothDevice;
2022 import android.content.BroadcastReceiver;
2123 import android.content.Context;
@@ -23,6 +25,7 @@ import android.content.DialogInterface;
2325 import android.content.Intent;
2426 import android.content.IntentFilter;
2527 import android.os.Bundle;
28+import android.telephony.TelephonyManager;
2629 import android.util.Log;
2730 import android.view.View;
2831 import android.widget.Button;
@@ -30,12 +33,11 @@ import android.widget.TextView;
3033
3134 import androidx.preference.Preference;
3235
36+import com.android.internal.annotations.VisibleForTesting;
3337 import com.android.internal.app.AlertActivity;
3438 import com.android.internal.app.AlertController;
3539 import com.android.settings.R;
3640
37-import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
38-
3941 /**
4042 * BluetoothPermissionActivity shows a dialog for accepting incoming
4143 * profile connection request from untrusted devices.
@@ -51,8 +53,6 @@ public class BluetoothPermissionActivity extends AlertActivity implements
5153 private TextView messageView;
5254 private Button mOkButton;
5355 private BluetoothDevice mDevice;
54- private String mReturnPackage = null;
55- private String mReturnClass = null;
5656
5757 private int mRequestType = 0;
5858 private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@@ -89,21 +89,19 @@ public class BluetoothPermissionActivity extends AlertActivity implements
8989 }
9090
9191 mDevice = i.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
92- mReturnPackage = i.getStringExtra(BluetoothDevice.EXTRA_PACKAGE_NAME);
93- mReturnClass = i.getStringExtra(BluetoothDevice.EXTRA_CLASS_NAME);
9492 mRequestType = i.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
9593 BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
9694
9795 if(DEBUG) Log.i(TAG, "onCreate() Request type: " + mRequestType);
9896
9997 if (mRequestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION) {
100- showDialog(getString(R.string.bluetooth_connection_permission_request), mRequestType);
98+ showDialog(getString(R.string.bluetooth_connect_access_dialog_title), mRequestType);
10199 } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
102100 showDialog(getString(R.string.bluetooth_phonebook_access_dialog_title), mRequestType);
103101 } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
104102 showDialog(getString(R.string.bluetooth_message_access_dialog_title), mRequestType);
105103 } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
106- showDialog(getString(R.string.bluetooth_sap_request), mRequestType);
104+ showDialog(getString(R.string.bluetooth_sim_card_access_dialog_title), mRequestType);
107105 }
108106 else {
109107 Log.e(TAG, "Error: bad request type: " + mRequestType);
@@ -136,9 +134,14 @@ public class BluetoothPermissionActivity extends AlertActivity implements
136134 p.mView = createSapDialogView();
137135 break;
138136 }
139- p.mPositiveButtonText = getString(R.string.allow);
137+ p.mPositiveButtonText = getString(
138+ requestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION
139+ ? R.string.bluetooth_connect_access_dialog_positive : R.string.allow);
140140 p.mPositiveButtonListener = this;
141- p.mNegativeButtonText = getString(R.string.deny);
141+ p.mNegativeButtonText = getString(
142+ requestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION
143+ ? R.string.bluetooth_connect_access_dialog_negative
144+ : R.string.request_manage_bluetooth_permission_dont_allow);
142145 p.mNegativeButtonListener = this;
143146 mOkButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
144147 setupAlert();
@@ -159,8 +162,8 @@ public class BluetoothPermissionActivity extends AlertActivity implements
159162 String mRemoteName = Utils.createRemoteName(this, mDevice);
160163 mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
161164 messageView = (TextView)mView.findViewById(R.id.message);
162- messageView.setText(getString(R.string.bluetooth_connection_dialog_text,
163- mRemoteName));
165+ messageView.setText(getString(R.string.bluetooth_connect_access_dialog_content,
166+ mRemoteName, mRemoteName));
164167 return mView;
165168 }
166169
@@ -184,10 +187,11 @@ public class BluetoothPermissionActivity extends AlertActivity implements
184187
185188 private View createSapDialogView() {
186189 String mRemoteName = Utils.createRemoteName(this, mDevice);
190+ TelephonyManager tm = getSystemService(TelephonyManager.class);
187191 mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
188192 messageView = (TextView)mView.findViewById(R.id.message);
189- messageView.setText(getString(R.string.bluetooth_sap_acceptance_dialog_text,
190- mRemoteName, mRemoteName));
193+ messageView.setText(getString(R.string.bluetooth_sim_card_access_dialog_content,
194+ mRemoteName, mRemoteName, tm.getLine1Number()));
191195 return mView;
192196 }
193197
@@ -202,14 +206,14 @@ public class BluetoothPermissionActivity extends AlertActivity implements
202206 sendReplyIntentToReceiver(false, true);
203207 }
204208
205- private void sendReplyIntentToReceiver(final boolean allowed, final boolean always) {
209+ @VisibleForTesting
210+ void sendReplyIntentToReceiver(final boolean allowed, final boolean always) {
206211 Intent intent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
207212
208- if (mReturnPackage != null && mReturnClass != null) {
209- intent.setClassName(mReturnPackage, mReturnClass);
213+ if (DEBUG) {
214+ Log.i(TAG, "sendReplyIntentToReceiver() Request type: " + mRequestType
215+ + " mReturnPackage");
210216 }
211- if (DEBUG) Log.i(TAG, "sendReplyIntentToReceiver() Request type: " + mRequestType +
212- " mReturnPackage" + mReturnPackage + " mReturnClass" + mReturnClass);
213217
214218 intent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT,
215219 allowed ? BluetoothDevice.CONNECTION_ACCESS_YES
--- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
@@ -56,8 +56,6 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
5656 Context mContext;
5757 int mRequestType;
5858 BluetoothDevice mDevice;
59- String mReturnPackage = null;
60- String mReturnClass = null;
6159
6260 @Override
6361 public void onReceive(Context context, Intent intent) {
@@ -77,11 +75,10 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
7775 mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
7876 mRequestType = intent.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
7977 BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION);
80- mReturnPackage = intent.getStringExtra(BluetoothDevice.EXTRA_PACKAGE_NAME);
81- mReturnClass = intent.getStringExtra(BluetoothDevice.EXTRA_CLASS_NAME);
8278
83- if (DEBUG) Log.d(TAG, "onReceive request type: " + mRequestType + " return "
84- + mReturnPackage + "," + mReturnClass);
79+ if (DEBUG) {
80+ Log.d(TAG, "onReceive request type: " + mRequestType);
81+ }
8582
8683 // Even if the user has already made the choice, Bluetooth still may not know that if
8784 // the user preference data have not been migrated from Settings app's shared
@@ -110,8 +107,6 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
110107 connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
111108 mRequestType);
112109 connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
113- connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_PACKAGE_NAME, mReturnPackage);
114- connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_CLASS_NAME, mReturnClass);
115110
116111 String deviceAddress = mDevice != null ? mDevice.getAddress() : null;
117112 String deviceName = mDevice != null ? mDevice.getName() : null;
@@ -149,13 +144,17 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
149144 R.string.bluetooth_message_access_notification_content);
150145 break;
151146 case BluetoothDevice.REQUEST_TYPE_SIM_ACCESS:
152- title = context.getString(R.string.bluetooth_sap_request);
153- message = context.getString(R.string.bluetooth_sap_acceptance_dialog_text,
147+ title = context.getString(
148+ R.string.bluetooth_sim_card_access_notification_title);
149+ message = context.getString(
150+ R.string.bluetooth_sim_card_access_notification_content,
154151 deviceAlias, deviceAlias);
155152 break;
156153 default:
157- title = context.getString(R.string.bluetooth_connection_permission_request);
158- message = context.getString(R.string.bluetooth_connection_dialog_text,
154+ title = context.getString(
155+ R.string.bluetooth_connect_access_notification_title);
156+ message = context.getString(
157+ R.string.bluetooth_connect_access_notification_content,
159158 deviceAlias, deviceAlias);
160159 break;
161160 }
@@ -230,7 +229,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
230229
231230 LocalBluetoothManager bluetoothManager = Utils.getLocalBtManager(mContext);
232231 CachedBluetoothDeviceManager cachedDeviceManager =
233- bluetoothManager.getCachedDeviceManager();
232+ bluetoothManager.getCachedDeviceManager();
234233 CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
235234 if (cachedDevice == null) {
236235 cachedDevice = cachedDeviceManager.addDevice(mDevice);
@@ -288,13 +287,9 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
288287 private void sendReplyIntentToReceiver(final boolean allowed) {
289288 Intent intent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
290289
291- if (mReturnPackage != null && mReturnClass != null) {
292- intent.setClassName(mReturnPackage, mReturnClass);
293- }
294-
295290 intent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT,
296- allowed ? BluetoothDevice.CONNECTION_ACCESS_YES
297- : BluetoothDevice.CONNECTION_ACCESS_NO);
291+ allowed ? BluetoothDevice.CONNECTION_ACCESS_YES
292+ : BluetoothDevice.CONNECTION_ACCESS_NO);
298293 intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
299294 intent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, mRequestType);
300295 mContext.sendBroadcast(intent, android.Manifest.permission.BLUETOOTH_ADMIN);
--- a/src/com/android/settings/bluetooth/DevicePickerActivity.java
+++ b/src/com/android/settings/bluetooth/DevicePickerActivity.java
@@ -16,6 +16,8 @@
1616
1717 package com.android.settings.bluetooth;
1818
19+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
20+
1921 import android.os.Bundle;
2022
2123 import androidx.fragment.app.FragmentActivity;
@@ -31,6 +33,7 @@ public final class DevicePickerActivity extends FragmentActivity {
3133 @Override
3234 protected void onCreate(Bundle savedInstanceState) {
3335 super.onCreate(savedInstanceState);
36+ getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
3437 setContentView(R.layout.bluetooth_device_picker);
3538 }
3639 }
--- a/src/com/android/settings/bluetooth/DevicePickerFragment.java
+++ b/src/com/android/settings/bluetooth/DevicePickerFragment.java
@@ -27,12 +27,15 @@ import android.content.Context;
2727 import android.content.Intent;
2828 import android.os.Bundle;
2929 import android.os.UserManager;
30+import android.util.Log;
31+import android.text.TextUtils;
3032 import android.view.Menu;
3133 import android.view.MenuInflater;
3234
3335 import androidx.annotation.VisibleForTesting;
3436
3537 import com.android.settings.R;
38+import com.android.settings.password.PasswordUtils;
3639 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
3740 import com.android.settingslib.core.AbstractPreferenceController;
3841
@@ -48,10 +51,16 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment {
4851
4952 @VisibleForTesting
5053 BluetoothProgressCategory mAvailableDevicesCategory;
54+ @VisibleForTesting
55+ Context mContext;
56+ @VisibleForTesting
57+ String mLaunchPackage;
58+ @VisibleForTesting
59+ String mLaunchClass;
60+ @VisibleForTesting
61+ String mCallingAppPackageName;
5162
5263 private boolean mNeedAuth;
53- private String mLaunchPackage;
54- private String mLaunchClass;
5564 private boolean mScanAllowed;
5665
5766 public DevicePickerFragment() {
@@ -85,6 +94,13 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment {
8594 getActivity().setTitle(getString(R.string.device_picker));
8695 UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
8796 mScanAllowed = !um.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH);
97+ mCallingAppPackageName = PasswordUtils.getCallingAppPackageName(
98+ getActivity().getActivityToken());
99+ if (!TextUtils.equals(mCallingAppPackageName, mLaunchPackage)) {
100+ Log.w(TAG, "sendDevicePickedIntent() launch package name is not equivalent to"
101+ + " calling package name!");
102+ }
103+ mContext = getContext();
88104 setHasOptionsMenu(true);
89105 }
90106
@@ -191,8 +207,11 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment {
191207 Intent intent = new Intent(BluetoothDevicePicker.ACTION_DEVICE_SELECTED);
192208 intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
193209 if (mLaunchPackage != null && mLaunchClass != null) {
194- intent.setClassName(mLaunchPackage, mLaunchClass);
210+ if (TextUtils.equals(mCallingAppPackageName, mLaunchPackage)) {
211+ intent.setClassName(mLaunchPackage, mLaunchClass);
212+ }
195213 }
196- getActivity().sendBroadcast(intent, Manifest.permission.BLUETOOTH_ADMIN);
214+
215+ mContext.sendBroadcast(intent, Manifest.permission.BLUETOOTH_ADMIN);
197216 }
198217 }
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -25,12 +25,15 @@ import android.net.wifi.WifiManager;
2525 import android.os.Bundle;
2626 import android.os.Handler;
2727 import android.os.Looper;
28+import android.os.UserManager;
2829 import android.view.Menu;
2930 import android.view.MenuInflater;
3031 import android.view.MenuItem;
3132
33+import androidx.annotation.VisibleForTesting;
34+
3235 import com.android.settings.R;
33-import com.android.settings.dashboard.DashboardFragment;
36+import com.android.settings.dashboard.RestrictedDashboardFragment;
3437 import com.android.settings.wifi.WifiConfigUiBase;
3538 import com.android.settings.wifi.WifiDialog;
3639 import com.android.settingslib.RestrictedLockUtils;
@@ -51,15 +54,45 @@ import java.util.List;
5154 * future, please develop in
5255 * {@link com.android.settings.wifi.details2.WifiNetworkDetailsFragment2}.
5356 */
54-public class WifiNetworkDetailsFragment extends DashboardFragment implements
57+public class WifiNetworkDetailsFragment extends RestrictedDashboardFragment implements
5558 WifiDialog.WifiDialogListener {
5659
5760 private static final String TAG = "WifiNetworkDetailsFrg";
5861
62+ @VisibleForTesting
63+ boolean mIsUiRestricted;
64+
5965 private AccessPoint mAccessPoint;
6066 private WifiDetailPreferenceController mWifiDetailPreferenceController;
6167 private List<WifiDialog.WifiDialogListener> mWifiDialogListeners = new ArrayList<>();
6268
69+ public WifiNetworkDetailsFragment() {
70+ super(UserManager.DISALLOW_CONFIG_WIFI);
71+ }
72+
73+ @Override
74+ public void onCreate(Bundle icicle) {
75+ super.onCreate(icicle);
76+ setIfOnlyAvailableForAdmins(true);
77+ mIsUiRestricted = isUiRestricted();
78+ }
79+
80+ @Override
81+ public void onStart() {
82+ super.onStart();
83+ if (mIsUiRestricted) {
84+ restrictUi();
85+ }
86+ }
87+
88+ @VisibleForTesting
89+ void restrictUi() {
90+ if (!isUiRestrictedByOnlyAdmin()) {
91+ getEmptyTextView().setText(R.string.wifi_empty_list_user_restricted);
92+ }
93+ getPreferenceScreen().removeAll();
94+ }
95+
6396 @Override
6497 public void onAttach(Context context) {
6598 mAccessPoint = new AccessPoint(context, getArguments());
@@ -102,9 +135,11 @@ public class WifiNetworkDetailsFragment extends DashboardFragment implements
102135
103136 @Override
104137 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
105- MenuItem item = menu.add(0, Menu.FIRST, 0, R.string.wifi_modify);
106- item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
107- item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
138+ if (!mIsUiRestricted) {
139+ MenuItem item = menu.add(0, Menu.FIRST, 0, R.string.wifi_modify);
140+ item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
141+ item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
142+ }
108143 super.onCreateOptionsMenu(menu, inflater);
109144 }
110145
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPermissionActivityTest.java
@@ -0,0 +1,58 @@
1+/*
2+ * Copyright (C) 2021 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+package com.android.settings.bluetooth;
18+
19+import static org.mockito.ArgumentMatchers.eq;
20+import static org.mockito.Mockito.spy;
21+import static org.mockito.Mockito.verify;
22+
23+import android.content.Context;
24+import android.content.Intent;
25+
26+import org.junit.Before;
27+import org.junit.Test;
28+import org.junit.runner.RunWith;
29+import org.mockito.ArgumentCaptor;
30+import org.mockito.MockitoAnnotations;
31+import org.robolectric.RobolectricTestRunner;
32+import org.robolectric.RuntimeEnvironment;
33+import org.robolectric.util.ReflectionHelpers;
34+
35+@RunWith(RobolectricTestRunner.class)
36+public class BluetoothPermissionActivityTest {
37+
38+ private BluetoothPermissionActivity mActivity;
39+ private Context mContext;
40+
41+ @Before
42+ public void setUp() {
43+ MockitoAnnotations.initMocks(this);
44+ mContext = spy(RuntimeEnvironment.application);
45+ mActivity = new BluetoothPermissionActivity();
46+ }
47+
48+ @Test
49+ public void sendBroadcastWithPermission() {
50+ final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
51+ ReflectionHelpers.setField(mActivity, "mBase", mContext);
52+
53+ mActivity.sendReplyIntentToReceiver(true, true);
54+
55+ verify(mContext).sendBroadcast(intentCaptor.capture(),
56+ eq("android.permission.BLUETOOTH_ADMIN"));
57+ }
58+}
--- a/tests/robotests/src/com/android/settings/bluetooth/DevicePickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/DevicePickerFragmentTest.java
@@ -16,28 +16,46 @@
1616
1717 package com.android.settings.bluetooth;
1818
19+import static com.google.common.truth.Truth.assertThat;
20+
21+import static org.mockito.ArgumentMatchers.eq;
22+import static org.mockito.Mockito.mock;
23+import static org.mockito.Mockito.never;
24+import static org.mockito.Mockito.spy;
1925 import static org.mockito.Mockito.verify;
26+import static org.mockito.Mockito.when;
27+
28+import android.bluetooth.BluetoothDevice;
29+import android.content.Context;
30+import android.content.Intent;
31+
32+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
2033
2134 import org.junit.Before;
2235 import org.junit.Test;
2336 import org.junit.runner.RunWith;
37+import org.mockito.ArgumentCaptor;
2438 import org.mockito.Mock;
2539 import org.mockito.MockitoAnnotations;
2640 import org.robolectric.RobolectricTestRunner;
41+import org.robolectric.RuntimeEnvironment;
2742
2843 @RunWith(RobolectricTestRunner.class)
2944 public class DevicePickerFragmentTest {
3045
3146 @Mock
3247 private BluetoothProgressCategory mAvailableDevicesCategory;
48+
3349 private DevicePickerFragment mFragment;
50+ private Context mContext;
3451
3552 @Before
3653 public void setUp() {
3754 MockitoAnnotations.initMocks(this);
3855
3956 mFragment = new DevicePickerFragment();
40-
57+ mContext = spy(RuntimeEnvironment.application);
58+ mFragment.mContext = mContext;
4159 mFragment.mAvailableDevicesCategory = mAvailableDevicesCategory;
4260 }
4361
@@ -49,4 +67,39 @@ public class DevicePickerFragmentTest {
4967
5068 verify(mAvailableDevicesCategory).setProgress(true);
5169 }
70+
71+ @Test
72+ public void callingPackageIsEqualToLaunchPackage_sendBroadcastToLaunchPackage() {
73+ final CachedBluetoothDevice cachedDevice = mock(CachedBluetoothDevice.class);
74+ final BluetoothDevice bluetoothDevice = mock(BluetoothDevice.class);
75+ final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
76+ when(cachedDevice.getDevice()).thenReturn(bluetoothDevice);
77+ mFragment.mSelectedDevice = bluetoothDevice;
78+ mFragment.mLaunchPackage = "com.android.settings";
79+ mFragment.mLaunchClass = "com.android.settings.bluetooth.BluetoothPermissionActivity";
80+ mFragment.mCallingAppPackageName = "com.android.settings";
81+
82+ mFragment.onDeviceBondStateChanged(cachedDevice, BluetoothDevice.BOND_BONDED);
83+
84+ verify(mContext).sendBroadcast(intentCaptor.capture(),
85+ eq("android.permission.BLUETOOTH_ADMIN"));
86+ assertThat(intentCaptor.getValue().getComponent().getPackageName())
87+ .isEqualTo(mFragment.mLaunchPackage);
88+ }
89+
90+ @Test
91+ public void callingPackageIsNotEqualToLaunchPackage_broadcastNotSend() {
92+ final CachedBluetoothDevice cachedDevice = mock(CachedBluetoothDevice.class);
93+ final BluetoothDevice bluetoothDevice = mock(BluetoothDevice.class);
94+ final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
95+ when(cachedDevice.getDevice()).thenReturn(bluetoothDevice);
96+ mFragment.mSelectedDevice = bluetoothDevice;
97+ mFragment.mLaunchPackage = "com.fake.settings";
98+ mFragment.mLaunchClass = "com.android.settings.bluetooth.BluetoothPermissionActivity";
99+ mFragment.mCallingAppPackageName = "com.android.settings";
100+
101+ mFragment.onDeviceBondStateChanged(cachedDevice, BluetoothDevice.BOND_BONDED);
102+
103+ verify(mContext, never()).sendBroadcast(intentCaptor.capture());
104+ }
52105 }
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiNetworkDetailsFragmentTest.java
@@ -0,0 +1,99 @@
1+/*
2+ * Copyright (C) 2021 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+package com.android.settings.wifi.details;
18+
19+import static org.mockito.ArgumentMatchers.anyInt;
20+import static org.mockito.ArgumentMatchers.eq;
21+import static org.mockito.Mockito.doReturn;
22+import static org.mockito.Mockito.mock;
23+import static org.mockito.Mockito.never;
24+import static org.mockito.Mockito.spy;
25+import static org.mockito.Mockito.verify;
26+
27+import android.view.Menu;
28+import android.view.MenuInflater;
29+import android.widget.TextView;
30+
31+import androidx.preference.PreferenceScreen;
32+
33+import com.android.settings.R;
34+
35+import org.junit.Before;
36+import org.junit.Test;
37+import org.junit.runner.RunWith;
38+import org.mockito.Mock;
39+import org.mockito.MockitoAnnotations;
40+import org.robolectric.RobolectricTestRunner;
41+
42+@RunWith(RobolectricTestRunner.class)
43+public class WifiNetworkDetailsFragmentTest {
44+
45+ @Mock
46+ Menu mMenu;
47+ private WifiNetworkDetailsFragment mFragment;
48+
49+ @Before
50+ public void setUp() {
51+ MockitoAnnotations.initMocks(this);
52+ mFragment = new WifiNetworkDetailsFragment();
53+ }
54+
55+ @Test
56+ public void onCreateOptionsMenu_uiRestricted_shouldNotAddEditMenu() {
57+ mFragment.mIsUiRestricted = true;
58+
59+ mFragment.onCreateOptionsMenu(mMenu, mock(MenuInflater.class));
60+
61+ verify(mMenu, never()).add(anyInt(), anyInt(), anyInt(), eq(R.string.wifi_modify));
62+ }
63+
64+ @Test
65+ public void restrictUi_shouldShowRestrictedText() {
66+ final WifiNetworkDetailsFragmentTest.FakeFragment
67+ fragment = spy(new WifiNetworkDetailsFragmentTest.FakeFragment());
68+ final PreferenceScreen screen = mock(PreferenceScreen.class);
69+ final TextView restrictedText = mock(TextView.class);
70+ doReturn(screen).when(fragment).getPreferenceScreen();
71+ doReturn(false).when(fragment).isUiRestrictedByOnlyAdmin();
72+ doReturn(restrictedText).when(fragment).getEmptyTextView();
73+
74+ fragment.restrictUi();
75+
76+ verify(restrictedText).setText(anyInt());
77+ }
78+
79+ @Test
80+ public void restrictUi_shouldRemoveAllPreferences() {
81+ final WifiNetworkDetailsFragmentTest.FakeFragment
82+ fragment = spy(new WifiNetworkDetailsFragmentTest.FakeFragment());
83+ final PreferenceScreen screen = mock(PreferenceScreen.class);
84+ doReturn(screen).when(fragment).getPreferenceScreen();
85+ doReturn(true).when(fragment).isUiRestrictedByOnlyAdmin();
86+
87+ fragment.restrictUi();
88+
89+ verify(screen).removeAll();
90+ }
91+
92+ // Fake WifiNetworkDetailsFragment to override the protected method as public.
93+ public class FakeFragment extends WifiNetworkDetailsFragment {
94+ @Override
95+ public boolean isUiRestrictedByOnlyAdmin() {
96+ return super.isUiRestrictedByOnlyAdmin();
97+ }
98+ }
99+}
\ No newline at end of file