Make GlobalActionsDialog injectable.
Bug: 147493050 Test: atest SystemUITests && manual. Change-Id: Ibfa841b39fc5083cf679224b9c277c5a92e58e0b
This commit is contained in:
@@ -21,9 +21,12 @@ import com.android.systemui.appops.AppOpsController;
|
||||
import com.android.systemui.appops.AppOpsControllerImpl;
|
||||
import com.android.systemui.classifier.FalsingManagerProxy;
|
||||
import com.android.systemui.doze.DozeHost;
|
||||
import com.android.systemui.globalactions.GlobalActionsComponent;
|
||||
import com.android.systemui.globalactions.GlobalActionsImpl;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.plugins.DarkIconDispatcher;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.plugins.GlobalActions;
|
||||
import com.android.systemui.plugins.VolumeDialogController;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.power.PowerNotificationWarnings;
|
||||
@@ -96,6 +99,17 @@ public abstract class DependencyBinder {
|
||||
public abstract BluetoothController provideBluetoothController(
|
||||
BluetoothControllerImpl controllerImpl);
|
||||
|
||||
/**
|
||||
*/
|
||||
@Binds
|
||||
public abstract GlobalActions provideGlobalActions(GlobalActionsImpl controllerImpl);
|
||||
|
||||
/**
|
||||
*/
|
||||
@Binds
|
||||
public abstract GlobalActions.GlobalActionsManager provideGlobalActionsManager(
|
||||
GlobalActionsComponent controllerImpl);
|
||||
|
||||
/**
|
||||
*/
|
||||
@Binds
|
||||
|
||||
@@ -26,17 +26,24 @@ import android.app.KeyguardManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.WallpaperManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.trust.TrustManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.hardware.SensorPrivacyManager;
|
||||
import android.media.AudioManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.os.Vibrator;
|
||||
import android.service.dreams.DreamService;
|
||||
import android.service.dreams.IDreamManager;
|
||||
import android.telecom.TelecomManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerGlobal;
|
||||
@@ -66,6 +73,12 @@ public class SystemServicesModule {
|
||||
return context.getSystemService(AccessibilityManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static ActivityManager provideActivityManager(Context context) {
|
||||
return context.getSystemService(ActivityManager.class);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
static AlarmManager provideAlarmManager(Context context) {
|
||||
@@ -74,10 +87,21 @@ public class SystemServicesModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static ActivityManager provideActivityManager(Context context) {
|
||||
return context.getSystemService(ActivityManager.class);
|
||||
static AudioManager provideAudioManager(Context context) {
|
||||
return context.getSystemService(AudioManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static ConnectivityManager provideConnectivityManagager(Context context) {
|
||||
return context.getSystemService(ConnectivityManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static ContentResolver provideContentResolver(Context context) {
|
||||
return context.getContentResolver();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@DisplayId
|
||||
@@ -183,6 +207,31 @@ public class SystemServicesModule {
|
||||
return context.getSystemService(SensorPrivacyManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static TelecomManager provideTelecomManager(Context context) {
|
||||
return context.getSystemService(TelecomManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static TelephonyManager provideTelephonyManager(Context context) {
|
||||
return context.getSystemService(TelephonyManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static TrustManager provideTrustManager(Context context) {
|
||||
return context.getSystemService(TrustManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Nullable
|
||||
static Vibrator provideVibrator(Context context) {
|
||||
return context.getSystemService(Vibrator.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static UserManager provideUserManager(Context context) {
|
||||
|
||||
@@ -19,7 +19,6 @@ import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.SystemUI;
|
||||
import com.android.systemui.plugins.GlobalActions;
|
||||
import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
|
||||
@@ -29,6 +28,7 @@ import com.android.systemui.statusbar.policy.ExtensionController;
|
||||
import com.android.systemui.statusbar.policy.ExtensionController.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
@@ -38,23 +38,29 @@ import javax.inject.Singleton;
|
||||
public class GlobalActionsComponent extends SystemUI implements Callbacks, GlobalActionsManager {
|
||||
|
||||
private final CommandQueue mCommandQueue;
|
||||
private final ExtensionController mExtensionController;
|
||||
private final Provider<GlobalActions> mGlobalActionsProvider;
|
||||
private GlobalActions mPlugin;
|
||||
private Extension<GlobalActions> mExtension;
|
||||
private IStatusBarService mBarService;
|
||||
|
||||
@Inject
|
||||
public GlobalActionsComponent(Context context, CommandQueue commandQueue) {
|
||||
public GlobalActionsComponent(Context context, CommandQueue commandQueue,
|
||||
ExtensionController extensionController,
|
||||
Provider<GlobalActions> globalActionsProvider) {
|
||||
super(context);
|
||||
mCommandQueue = commandQueue;
|
||||
mExtensionController = extensionController;
|
||||
mGlobalActionsProvider = globalActionsProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
mBarService = IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
||||
mExtension = Dependency.get(ExtensionController.class).newExtension(GlobalActions.class)
|
||||
mExtension = mExtensionController.newExtension(GlobalActions.class)
|
||||
.withPlugin(GlobalActions.class)
|
||||
.withDefault(() -> new GlobalActionsImpl(mContext, mCommandQueue))
|
||||
.withDefault(mGlobalActionsProvider::get)
|
||||
.withCallback(this::onExtensionCallback)
|
||||
.build();
|
||||
mPlugin = mExtension.get();
|
||||
|
||||
@@ -21,8 +21,10 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOM
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Dialog;
|
||||
import android.app.IActivityManager;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.StatusBarManager;
|
||||
@@ -30,11 +32,13 @@ import android.app.WallpaperManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.trust.TrustManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.database.ContentObserver;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.AudioManager;
|
||||
@@ -44,13 +48,11 @@ import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.Settings;
|
||||
import android.service.dreams.DreamService;
|
||||
import android.service.dreams.IDreamManager;
|
||||
import android.sysprop.TelephonyProperties;
|
||||
import android.telecom.TelecomManager;
|
||||
@@ -92,6 +94,7 @@ import com.android.systemui.MultiListLayout;
|
||||
import com.android.systemui.MultiListLayout.MultiListAdapter;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.colorextraction.SysuiColorExtractor;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
|
||||
import com.android.systemui.plugins.GlobalActionsPanelPlugin;
|
||||
@@ -106,6 +109,8 @@ import com.android.systemui.volume.SystemUIInterpolators.LogAccelerateInterpolat
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Helper to show the global actions dialog. Each item is an {@link Action} that
|
||||
* may show depending on whether the keyguard is showing, and whether the device
|
||||
@@ -146,6 +151,13 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final KeyguardManager mKeyguardManager;
|
||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||
private final ContentResolver mContentResolver;
|
||||
private final Resources mResources;
|
||||
private final UserManager mUserManager;
|
||||
private final TrustManager mTrustManager;
|
||||
private final IActivityManager mIActivityManager;
|
||||
private final TelecomManager mTelecomManager;
|
||||
private final MetricsLogger mMetricsLogger;
|
||||
|
||||
private ArrayList<Action> mItems;
|
||||
private ActionsDialog mDialog;
|
||||
@@ -161,8 +173,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
private boolean mIsWaitingForEcmExit = false;
|
||||
private boolean mHasTelephony;
|
||||
private boolean mHasVibrator;
|
||||
private boolean mHasLogoutButton;
|
||||
private boolean mHasLockdownButton;
|
||||
private final boolean mShowSilentToggle;
|
||||
private final EmergencyAffordanceManager mEmergencyAffordanceManager;
|
||||
private final ScreenshotHelper mScreenshotHelper;
|
||||
@@ -173,17 +183,32 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
/**
|
||||
* @param context everything needs a context :(
|
||||
*/
|
||||
public GlobalActionsDialog(Context context, GlobalActionsManager windowManagerFuncs) {
|
||||
@Inject
|
||||
public GlobalActionsDialog(Context context, GlobalActionsManager windowManagerFuncs,
|
||||
AudioManager audioManager, IDreamManager iDreamManager,
|
||||
DevicePolicyManager devicePolicyManager, LockPatternUtils lockPatternUtils,
|
||||
KeyguardManager keyguardManager, BroadcastDispatcher broadcastDispatcher,
|
||||
ConnectivityManager connectivityManager, TelephonyManager telephonyManager,
|
||||
ContentResolver contentResolver, @Nullable Vibrator vibrator, @Main Resources resources,
|
||||
ConfigurationController configurationController, ActivityStarter activityStarter,
|
||||
KeyguardStateController keyguardStateController, UserManager userManager,
|
||||
TrustManager trustManager, IActivityManager iActivityManager,
|
||||
TelecomManager telecomManager, MetricsLogger metricsLogger) {
|
||||
mContext = new ContextThemeWrapper(context, com.android.systemui.R.style.qs_theme);
|
||||
mWindowManagerFuncs = windowManagerFuncs;
|
||||
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||
mDreamManager = IDreamManager.Stub.asInterface(
|
||||
ServiceManager.getService(DreamService.DREAM_SERVICE));
|
||||
mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService(
|
||||
Context.DEVICE_POLICY_SERVICE);
|
||||
mLockPatternUtils = new LockPatternUtils(mContext);
|
||||
mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
mBroadcastDispatcher = Dependency.get(BroadcastDispatcher.class);
|
||||
mAudioManager = audioManager;
|
||||
mDreamManager = iDreamManager;
|
||||
mDevicePolicyManager = devicePolicyManager;
|
||||
mLockPatternUtils = lockPatternUtils;
|
||||
mKeyguardManager = keyguardManager;
|
||||
mBroadcastDispatcher = broadcastDispatcher;
|
||||
mContentResolver = contentResolver;
|
||||
mResources = resources;
|
||||
mUserManager = userManager;
|
||||
mTrustManager = trustManager;
|
||||
mIActivityManager = iActivityManager;
|
||||
mTelecomManager = telecomManager;
|
||||
mMetricsLogger = metricsLogger;
|
||||
|
||||
// receive broadcasts
|
||||
IntentFilter filter = new IntentFilter();
|
||||
@@ -192,32 +217,25 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
filter.addAction(TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
|
||||
mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager)
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
mHasTelephony = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
|
||||
mHasTelephony = connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
|
||||
|
||||
// get notified of phone state changes
|
||||
TelephonyManager telephonyManager =
|
||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
contentResolver.registerContentObserver(
|
||||
Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON), true,
|
||||
mAirplaneModeObserver);
|
||||
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
mHasVibrator = vibrator != null && vibrator.hasVibrator();
|
||||
|
||||
mShowSilentToggle = SHOW_SILENT_TOGGLE && !mContext.getResources().getBoolean(
|
||||
mShowSilentToggle = SHOW_SILENT_TOGGLE && !resources.getBoolean(
|
||||
R.bool.config_useFixedVolume);
|
||||
|
||||
mEmergencyAffordanceManager = new EmergencyAffordanceManager(context);
|
||||
mScreenshotHelper = new ScreenshotHelper(context);
|
||||
mScreenRecordHelper = new ScreenRecordHelper(context);
|
||||
|
||||
Dependency.get(ConfigurationController.class).addCallback(this);
|
||||
configurationController.addCallback(this);
|
||||
|
||||
mActivityStarter = Dependency.get(ActivityStarter.class);
|
||||
KeyguardStateController keyguardStateController =
|
||||
Dependency.get(KeyguardStateController.class);
|
||||
mActivityStarter = activityStarter;
|
||||
keyguardStateController.addCallback(new KeyguardStateController.Callback() {
|
||||
@Override
|
||||
public void onUnlockedChanged() {
|
||||
@@ -343,12 +361,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
onAirplaneModeChanged();
|
||||
|
||||
mItems = new ArrayList<Action>();
|
||||
String[] defaultActions = mContext.getResources().getStringArray(
|
||||
R.array.config_globalActionsList);
|
||||
String[] defaultActions = mResources.getStringArray(R.array.config_globalActionsList);
|
||||
|
||||
ArraySet<String> addedKeys = new ArraySet<String>();
|
||||
mHasLogoutButton = false;
|
||||
mHasLockdownButton = false;
|
||||
for (int i = 0; i < defaultActions.length; i++) {
|
||||
String actionKey = defaultActions[i];
|
||||
if (addedKeys.contains(actionKey)) {
|
||||
@@ -360,7 +375,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
} else if (GLOBAL_ACTION_KEY_AIRPLANE.equals(actionKey)) {
|
||||
mItems.add(mAirplaneModeOn);
|
||||
} else if (GLOBAL_ACTION_KEY_BUGREPORT.equals(actionKey)) {
|
||||
if (Settings.Global.getInt(mContext.getContentResolver(),
|
||||
if (Settings.Global.getInt(mContentResolver,
|
||||
Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0 && isCurrentUserOwner()) {
|
||||
mItems.add(new BugReportAction());
|
||||
}
|
||||
@@ -375,11 +390,10 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
} else if (GLOBAL_ACTION_KEY_SETTINGS.equals(actionKey)) {
|
||||
mItems.add(getSettingsAction());
|
||||
} else if (GLOBAL_ACTION_KEY_LOCKDOWN.equals(actionKey)) {
|
||||
if (Settings.Secure.getIntForUser(mContext.getContentResolver(),
|
||||
if (Settings.Secure.getIntForUser(mContentResolver,
|
||||
Settings.Secure.LOCKDOWN_IN_POWER_MENU, 0, getCurrentUser().id) != 0
|
||||
&& shouldDisplayLockdown()) {
|
||||
mItems.add(getLockdownAction());
|
||||
mHasLockdownButton = true;
|
||||
}
|
||||
} else if (GLOBAL_ACTION_KEY_VOICEASSIST.equals(actionKey)) {
|
||||
mItems.add(getVoiceAssistAction());
|
||||
@@ -393,7 +407,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
if (mDevicePolicyManager.isLogoutEnabled()
|
||||
&& getCurrentUser().id != UserHandle.USER_SYSTEM) {
|
||||
mItems.add(new LogoutAction());
|
||||
mHasLogoutButton = true;
|
||||
}
|
||||
} else if (GLOBAL_ACTION_KEY_EMERGENCY.equals(actionKey)) {
|
||||
if (!mEmergencyAffordanceManager.needsEmergencyAffordance()) {
|
||||
@@ -474,8 +487,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
|
||||
@Override
|
||||
public boolean onLongPress() {
|
||||
UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
|
||||
if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
|
||||
mWindowManagerFuncs.reboot(true);
|
||||
return true;
|
||||
}
|
||||
@@ -560,9 +572,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
MetricsLogger.action(mContext, MetricsEvent.ACTION_EMERGENCY_DIALER_FROM_POWER_MENU);
|
||||
Intent intent = mContext.getSystemService(TelecomManager.class)
|
||||
.createLaunchEmergencyDialerIntent(null /* number */);
|
||||
mMetricsLogger.action(MetricsEvent.ACTION_EMERGENCY_DIALER_FROM_POWER_MENU);
|
||||
Intent intent = mTelecomManager.createLaunchEmergencyDialerIntent(null /* number */);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
@@ -579,8 +590,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
|
||||
@Override
|
||||
public boolean onLongPress() {
|
||||
UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
|
||||
if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
|
||||
mWindowManagerFuncs.reboot(true);
|
||||
return true;
|
||||
}
|
||||
@@ -618,8 +628,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
@Override
|
||||
public void run() {
|
||||
mScreenshotHelper.takeScreenshot(1, true, true, mHandler, null);
|
||||
MetricsLogger.action(mContext,
|
||||
MetricsEvent.ACTION_SCREENSHOT_POWER_MENU);
|
||||
mMetricsLogger.action(MetricsEvent.ACTION_SCREENSHOT_POWER_MENU);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
@@ -666,11 +675,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
public void run() {
|
||||
try {
|
||||
// Take an "interactive" bugreport.
|
||||
MetricsLogger.action(mContext,
|
||||
mMetricsLogger.action(
|
||||
MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_INTERACTIVE);
|
||||
if (!ActivityManager.getService().launchBugReportHandlerApp()) {
|
||||
if (!mIActivityManager.launchBugReportHandlerApp()) {
|
||||
Log.w(TAG, "Bugreport handler could not be launched");
|
||||
ActivityManager.getService().requestInteractiveBugReport();
|
||||
mIActivityManager.requestInteractiveBugReport();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
@@ -687,8 +696,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
}
|
||||
try {
|
||||
// Take a "full" bugreport.
|
||||
MetricsLogger.action(mContext, MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_FULL);
|
||||
ActivityManager.getService().requestFullBugReport();
|
||||
mMetricsLogger.action(MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_FULL);
|
||||
mIActivityManager.requestFullBugReport();
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
return false;
|
||||
@@ -726,8 +735,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
mHandler.postDelayed(() -> {
|
||||
try {
|
||||
int currentUserId = getCurrentUser().id;
|
||||
ActivityManager.getService().switchUser(UserHandle.USER_SYSTEM);
|
||||
ActivityManager.getService().stopUser(currentUserId, true /*force*/, null);
|
||||
mIActivityManager.switchUser(UserHandle.USER_SYSTEM);
|
||||
mIActivityManager.stopUser(currentUserId, true /*force*/, null);
|
||||
} catch (RemoteException re) {
|
||||
Log.e(TAG, "Couldn't logout user " + re);
|
||||
}
|
||||
@@ -834,20 +843,18 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
}
|
||||
|
||||
private void lockProfiles() {
|
||||
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
final TrustManager tm = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE);
|
||||
final int currentUserId = getCurrentUser().id;
|
||||
final int[] profileIds = um.getEnabledProfileIds(currentUserId);
|
||||
final int[] profileIds = mUserManager.getEnabledProfileIds(currentUserId);
|
||||
for (final int id : profileIds) {
|
||||
if (id != currentUserId) {
|
||||
tm.setDeviceLockedForUser(id, true);
|
||||
mTrustManager.setDeviceLockedForUser(id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UserInfo getCurrentUser() {
|
||||
try {
|
||||
return ActivityManager.getService().getCurrentUser();
|
||||
return mIActivityManager.getCurrentUser();
|
||||
} catch (RemoteException re) {
|
||||
return null;
|
||||
}
|
||||
@@ -859,9 +866,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
}
|
||||
|
||||
private void addUsersToMenu(ArrayList<Action> items) {
|
||||
UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
if (um.isUserSwitcherEnabled()) {
|
||||
List<UserInfo> users = um.getUsers();
|
||||
if (mUserManager.isUserSwitcherEnabled()) {
|
||||
List<UserInfo> users = mUserManager.getUsers();
|
||||
UserInfo currentUser = getCurrentUser();
|
||||
for (final UserInfo user : users) {
|
||||
if (user.supportsSwitchToByUser()) {
|
||||
@@ -875,7 +881,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
+ (isCurrentUser ? " \u2714" : "")) {
|
||||
public void onPress() {
|
||||
try {
|
||||
ActivityManager.getService().switchUser(user.id);
|
||||
mIActivityManager.switchUser(user.id);
|
||||
} catch (RemoteException re) {
|
||||
Log.e(TAG, "Couldn't switch user " + re);
|
||||
}
|
||||
@@ -932,7 +938,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void onShow(DialogInterface dialog) {
|
||||
MetricsLogger.visible(mContext, MetricsEvent.POWER_MENU);
|
||||
mMetricsLogger.visible(MetricsEvent.POWER_MENU);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1492,7 +1498,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
if (mHasTelephony) return;
|
||||
|
||||
boolean airplaneModeOn = Settings.Global.getInt(
|
||||
mContext.getContentResolver(),
|
||||
mContentResolver,
|
||||
Settings.Global.AIRPLANE_MODE_ON,
|
||||
0) == 1;
|
||||
mAirplaneState = airplaneModeOn ? ToggleAction.State.On : ToggleAction.State.Off;
|
||||
@@ -1504,7 +1510,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
*/
|
||||
private void changeAirplaneModeSystemSetting(boolean on) {
|
||||
Settings.Global.putInt(
|
||||
mContext.getContentResolver(),
|
||||
mContentResolver,
|
||||
Settings.Global.AIRPLANE_MODE_ON,
|
||||
on ? 1 : 0);
|
||||
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
|
||||
@@ -45,24 +45,32 @@ import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
import com.android.systemui.statusbar.policy.ExtensionController;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks,
|
||||
PluginListener<GlobalActionsPanelPlugin> {
|
||||
|
||||
private static final float SHUTDOWN_SCRIM_ALPHA = 0.95f;
|
||||
|
||||
private final Context mContext;
|
||||
private final Lazy<GlobalActionsDialog> mGlobalActionsDialogLazy;
|
||||
private final KeyguardStateController mKeyguardStateController;
|
||||
private final DeviceProvisionedController mDeviceProvisionedController;
|
||||
private final ExtensionController.Extension<GlobalActionsPanelPlugin> mPanelExtension;
|
||||
private GlobalActionsPanelPlugin mPlugin;
|
||||
private final CommandQueue mCommandQueue;
|
||||
private GlobalActionsDialog mGlobalActions;
|
||||
private GlobalActionsDialog mGlobalActionsDialog;
|
||||
private boolean mDisabled;
|
||||
private final PluginManager mPluginManager;
|
||||
private final String mPluginPackageName;
|
||||
|
||||
public GlobalActionsImpl(Context context, CommandQueue commandQueue) {
|
||||
@Inject
|
||||
public GlobalActionsImpl(Context context, CommandQueue commandQueue,
|
||||
Lazy<GlobalActionsDialog> globalActionsDialogLazy) {
|
||||
mContext = context;
|
||||
mGlobalActionsDialogLazy = globalActionsDialogLazy;
|
||||
mKeyguardStateController = Dependency.get(KeyguardStateController.class);
|
||||
mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
|
||||
mPluginManager = Dependency.get(PluginManager.class);
|
||||
@@ -83,19 +91,17 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks,
|
||||
mCommandQueue.removeCallback(this);
|
||||
mPluginManager.removePluginListener(this);
|
||||
if (mPlugin != null) mPlugin.onDestroy();
|
||||
if (mGlobalActions != null) {
|
||||
mGlobalActions.destroy();
|
||||
mGlobalActions = null;
|
||||
if (mGlobalActionsDialog != null) {
|
||||
mGlobalActionsDialog.destroy();
|
||||
mGlobalActionsDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showGlobalActions(GlobalActionsManager manager) {
|
||||
if (mDisabled) return;
|
||||
if (mGlobalActions == null) {
|
||||
mGlobalActions = new GlobalActionsDialog(mContext, manager);
|
||||
}
|
||||
mGlobalActions.showDialog(mKeyguardStateController.isShowing(),
|
||||
mGlobalActionsDialog = mGlobalActionsDialogLazy.get();
|
||||
mGlobalActionsDialog.showDialog(mKeyguardStateController.isShowing(),
|
||||
mDeviceProvisionedController.isDeviceProvisioned(),
|
||||
mPlugin != null ? mPlugin : mPanelExtension.get());
|
||||
Dependency.get(KeyguardUpdateMonitor.class).requestFaceAuth();
|
||||
@@ -189,8 +195,8 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks,
|
||||
final boolean disabled = (state2 & DISABLE2_GLOBAL_ACTIONS) != 0;
|
||||
if (displayId != mContext.getDisplayId() || disabled == mDisabled) return;
|
||||
mDisabled = disabled;
|
||||
if (disabled && mGlobalActions != null) {
|
||||
mGlobalActions.dismissDialog();
|
||||
if (disabled && mGlobalActionsDialog != null) {
|
||||
mGlobalActionsDialog.dismissDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user