When in guest mode hide the rename button
Bug: 198173108 Test: local test Change-Id: I29eb227104baa43ab8223f86a6a5d9cecd612bde
This commit is contained in:
@@ -23,6 +23,7 @@ import android.app.settings.SettingsEnums;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
@@ -62,6 +63,7 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
|
||||
interface TestDataFactory {
|
||||
CachedBluetoothDevice getDevice(String deviceAddress);
|
||||
LocalBluetoothManager getManager(Context context);
|
||||
UserManager getUserManager();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -74,6 +76,8 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
|
||||
@VisibleForTesting
|
||||
CachedBluetoothDevice mCachedDevice;
|
||||
|
||||
private UserManager mUserManager;
|
||||
|
||||
public BluetoothDeviceDetailsFragment() {
|
||||
super(DISALLOW_CONFIG_BLUETOOTH);
|
||||
}
|
||||
@@ -96,6 +100,15 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
|
||||
return mManager.getCachedDeviceManager().findDevice(remoteDevice);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
UserManager getUserManager() {
|
||||
if (sTestDataFactory != null) {
|
||||
return sTestDataFactory.getUserManager();
|
||||
}
|
||||
|
||||
return getSystemService(UserManager.class);
|
||||
}
|
||||
|
||||
public static BluetoothDeviceDetailsFragment newInstance(String deviceAddress) {
|
||||
Bundle args = new Bundle(1);
|
||||
args.putString(KEY_DEVICE_ADDRESS, deviceAddress);
|
||||
@@ -109,6 +122,7 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
|
||||
mDeviceAddress = getArguments().getString(KEY_DEVICE_ADDRESS);
|
||||
mManager = getLocalBluetoothManager(context);
|
||||
mCachedDevice = getCachedDevice(mDeviceAddress);
|
||||
mUserManager = getUserManager();
|
||||
super.onAttach(context);
|
||||
if (mCachedDevice == null) {
|
||||
// Close this page if device is null with invalid device mac address
|
||||
@@ -160,9 +174,12 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
MenuItem item = menu.add(0, EDIT_DEVICE_NAME_ITEM_ID, 0, R.string.bluetooth_rename_button);
|
||||
item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
if (!mUserManager.isGuestUser()) {
|
||||
MenuItem item = menu.add(0, EDIT_DEVICE_NAME_ITEM_ID, 0,
|
||||
R.string.bluetooth_rename_button);
|
||||
item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user