Update usage of ActivityManagerNative.
Bug: 30977067 Test: N/A Change-Id: I46e37a09cff059d2784a819bc2651d6973fbd268
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManagerNative;
|
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@@ -97,7 +96,7 @@ public class BugreportPreference extends CustomDialogPreference {
|
|||||||
|
|
||||||
private void takeBugreport(int bugreportType) {
|
private void takeBugreport(int bugreportType) {
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().requestBugReport(bugreportType);
|
ActivityManager.getService().requestBugReport(bugreportType);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "error taking bugreport (bugreportType=" + bugreportType + ")", e);
|
Log.e(TAG, "error taking bugreport (bugreportType=" + bugreportType + ")", e);
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,6 @@ package com.android.settings;
|
|||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManagerNative;
|
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.IActivityManager;
|
import android.app.IActivityManager;
|
||||||
@@ -213,7 +212,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends OptionsMenuFra
|
|||||||
int taskId = getActivity().getIntent().getIntExtra(Intent.EXTRA_TASK_ID, -1);
|
int taskId = getActivity().getIntent().getIntExtra(Intent.EXTRA_TASK_ID, -1);
|
||||||
if (taskId != -1) {
|
if (taskId != -1) {
|
||||||
try {
|
try {
|
||||||
IActivityManager activityManager = ActivityManagerNative.getDefault();
|
IActivityManager activityManager = ActivityManager.getService();
|
||||||
final ActivityOptions options = ActivityOptions.makeBasic();
|
final ActivityOptions options = ActivityOptions.makeBasic();
|
||||||
options.setLaunchStackId(ActivityManager.StackId.INVALID_STACK_ID);
|
options.setLaunchStackId(ActivityManager.StackId.INVALID_STACK_ID);
|
||||||
activityManager.startActivityFromRecents(taskId, options.toBundle());
|
activityManager.startActivityFromRecents(taskId, options.toBundle());
|
||||||
|
@@ -418,7 +418,7 @@ public final class CredentialStorage extends Activity {
|
|||||||
|
|
||||||
final int launchedFromUserId;
|
final int launchedFromUserId;
|
||||||
try {
|
try {
|
||||||
int launchedFromUid = android.app.ActivityManagerNative.getDefault()
|
int launchedFromUid = android.app.ActivityManager.getService()
|
||||||
.getLaunchedFromUid(getActivityToken());
|
.getLaunchedFromUid(getActivityToken());
|
||||||
if (launchedFromUid == -1) {
|
if (launchedFromUid == -1) {
|
||||||
Log.e(TAG, ACTION_INSTALL + " must be started with startActivityForResult");
|
Log.e(TAG, ACTION_INSTALL + " must be started with startActivityForResult");
|
||||||
|
@@ -18,7 +18,7 @@ package com.android.settings;
|
|||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.app.AppOpsManager.PackageOps;
|
import android.app.AppOpsManager.PackageOps;
|
||||||
@@ -807,7 +807,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
String wv_package = mWebViewUpdateService.getCurrentWebViewPackageName();
|
String wv_package = mWebViewUpdateService.getCurrentWebViewPackageName();
|
||||||
ActivityManagerNative.getDefault().killPackageDependents(
|
ActivityManager.getService().killPackageDependents(
|
||||||
wv_package, UserHandle.USER_ALL);
|
wv_package, UserHandle.USER_ALL);
|
||||||
} catch(RemoteException e) {
|
} catch(RemoteException e) {
|
||||||
}
|
}
|
||||||
@@ -865,7 +865,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
private void writeDebuggerOptions() {
|
private void writeDebuggerOptions() {
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().setDebugApp(
|
ActivityManager.getService().setDebugApp(
|
||||||
mDebugApp, mWaitForDebugger.isChecked(), true);
|
mDebugApp, mWaitForDebugger.isChecked(), true);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
}
|
}
|
||||||
@@ -908,7 +908,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
private static void resetDebuggerOptions() {
|
private static void resetDebuggerOptions() {
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().setDebugApp(
|
ActivityManager.getService().setDebugApp(
|
||||||
null, false, true);
|
null, false, true);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
}
|
}
|
||||||
@@ -1721,7 +1721,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
private void writeImmediatelyDestroyActivitiesOptions() {
|
private void writeImmediatelyDestroyActivitiesOptions() {
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().setAlwaysFinish(
|
ActivityManager.getService().setAlwaysFinish(
|
||||||
mImmediatelyDestroyActivities.isChecked());
|
mImmediatelyDestroyActivities.isChecked());
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
}
|
}
|
||||||
@@ -1795,7 +1795,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
private void updateAppProcessLimitOptions() {
|
private void updateAppProcessLimitOptions() {
|
||||||
try {
|
try {
|
||||||
int limit = ActivityManagerNative.getDefault().getProcessLimit();
|
int limit = ActivityManager.getService().getProcessLimit();
|
||||||
CharSequence[] values = mAppProcessLimit.getEntryValues();
|
CharSequence[] values = mAppProcessLimit.getEntryValues();
|
||||||
for (int i=0; i<values.length; i++) {
|
for (int i=0; i<values.length; i++) {
|
||||||
int val = Integer.parseInt(values[i].toString());
|
int val = Integer.parseInt(values[i].toString());
|
||||||
@@ -1817,7 +1817,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
private void writeAppProcessLimitOptions(Object newValue) {
|
private void writeAppProcessLimitOptions(Object newValue) {
|
||||||
try {
|
try {
|
||||||
int limit = newValue != null ? Integer.parseInt(newValue.toString()) : -1;
|
int limit = newValue != null ? Integer.parseInt(newValue.toString()) : -1;
|
||||||
ActivityManagerNative.getDefault().setProcessLimit(limit);
|
ActivityManager.getService().setProcessLimit(limit);
|
||||||
updateAppProcessLimitOptions();
|
updateAppProcessLimitOptions();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@@ -367,7 +367,7 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
try {
|
try {
|
||||||
// Don't allow the admin to put a dialog up in front
|
// Don't allow the admin to put a dialog up in front
|
||||||
// of us while we interact with the user.
|
// of us while we interact with the user.
|
||||||
ActivityManagerNative.getDefault().stopAppSwitches();
|
ActivityManager.getService().stopAppSwitches();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
mWaitingForRemoveMsg = true;
|
mWaitingForRemoveMsg = true;
|
||||||
@@ -426,7 +426,7 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
mWaitingForRemoveMsg = false;
|
mWaitingForRemoveMsg = false;
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().resumeAppSwitches();
|
ActivityManager.getService().resumeAppSwitches();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
|
mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
|
||||||
@@ -434,7 +434,7 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// Continue preventing anything from coming in front.
|
// Continue preventing anything from coming in front.
|
||||||
ActivityManagerNative.getDefault().stopAppSwitches();
|
ActivityManager.getService().stopAppSwitches();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
@@ -466,7 +466,7 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
mAppOps.setMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, pkg, mCurSysAppOpMode);
|
mAppOps.setMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, pkg, mCurSysAppOpMode);
|
||||||
mAppOps.setMode(AppOpsManager.OP_TOAST_WINDOW, uid, pkg, mCurToastAppOpMode);
|
mAppOps.setMode(AppOpsManager.OP_TOAST_WINDOW, uid, pkg, mCurToastAppOpMode);
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().resumeAppSwitches();
|
ActivityManager.getService().resumeAppSwitches();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,7 +494,7 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().resumeAppSwitches();
|
ActivityManager.getService().resumeAppSwitches();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
|
mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
|
||||||
|
@@ -18,7 +18,6 @@ package com.android.settings;
|
|||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManagerNative;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AppGlobals;
|
import android.app.AppGlobals;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@@ -648,7 +647,7 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
public static UserHandle getSecureTargetUser(IBinder activityToken,
|
public static UserHandle getSecureTargetUser(IBinder activityToken,
|
||||||
UserManager um, @Nullable Bundle arguments, @Nullable Bundle intentExtras) {
|
UserManager um, @Nullable Bundle arguments, @Nullable Bundle intentExtras) {
|
||||||
UserHandle currentUser = new UserHandle(UserHandle.myUserId());
|
UserHandle currentUser = new UserHandle(UserHandle.myUserId());
|
||||||
IActivityManager am = ActivityManagerNative.getDefault();
|
IActivityManager am = ActivityManager.getService();
|
||||||
try {
|
try {
|
||||||
String launchedFromPackage = am.getLaunchedFromPackage(activityToken);
|
String launchedFromPackage = am.getLaunchedFromPackage(activityToken);
|
||||||
boolean launchedFromSettingsApp = SETTINGS_PACKAGE_NAME.equals(launchedFromPackage);
|
boolean launchedFromSettingsApp = SETTINGS_PACKAGE_NAME.equals(launchedFromPackage);
|
||||||
@@ -698,7 +697,7 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
public static UserHandle getInsecureTargetUser(IBinder activityToken, @Nullable Bundle arguments,
|
public static UserHandle getInsecureTargetUser(IBinder activityToken, @Nullable Bundle arguments,
|
||||||
@Nullable Bundle intentExtras) {
|
@Nullable Bundle intentExtras) {
|
||||||
UserHandle currentUser = new UserHandle(UserHandle.myUserId());
|
UserHandle currentUser = new UserHandle(UserHandle.myUserId());
|
||||||
IActivityManager am = ActivityManagerNative.getDefault();
|
IActivityManager am = ActivityManager.getService();
|
||||||
try {
|
try {
|
||||||
UserHandle launchedFromUser = new UserHandle(UserHandle.getUserId(
|
UserHandle launchedFromUser = new UserHandle(UserHandle.getUserId(
|
||||||
am.getLaunchedFromUid(activityToken)));
|
am.getLaunchedFromUid(activityToken)));
|
||||||
@@ -1117,7 +1116,7 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
|
|
||||||
public static boolean unlockWorkProfileIfNecessary(Context context, int userId) {
|
public static boolean unlockWorkProfileIfNecessary(Context context, int userId) {
|
||||||
try {
|
try {
|
||||||
if (!ActivityManagerNative.getDefault().isUserRunning(userId,
|
if (!ActivityManager.getService().isUserRunning(userId,
|
||||||
ActivityManager.FLAG_AND_LOCKED)) {
|
ActivityManager.FLAG_AND_LOCKED)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManagerNative;
|
|
||||||
import android.app.ActivityThread;
|
import android.app.ActivityThread;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@@ -1320,7 +1319,7 @@ public class RunningState {
|
|||||||
for (int i=0; i<numProc; i++) {
|
for (int i=0; i<numProc; i++) {
|
||||||
pids[i] = mAllProcessItems.get(i).mPid;
|
pids[i] = mAllProcessItems.get(i).mPid;
|
||||||
}
|
}
|
||||||
long[] pss = ActivityManagerNative.getDefault()
|
long[] pss = ActivityManager.getService()
|
||||||
.getProcessPss(pids);
|
.getProcessPss(pids);
|
||||||
int bgIndex = 0;
|
int bgIndex = 0;
|
||||||
for (int i=0; i<pids.length; i++) {
|
for (int i=0; i<pids.length; i++) {
|
||||||
|
@@ -18,7 +18,6 @@ package com.android.settings.bluetooth;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManagerNative;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.inputmethod;
|
package com.android.settings.inputmethod;
|
||||||
|
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -63,7 +63,7 @@ class InputMethodSettingValuesWrapper {
|
|||||||
|
|
||||||
private static int getDefaultCurrentUserId() {
|
private static int getDefaultCurrentUserId() {
|
||||||
try {
|
try {
|
||||||
return ActivityManagerNative.getDefault().getCurrentUser().id;
|
return ActivityManager.getService().getCurrentUser().id;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "Couldn't get current user ID; guessing it's 0", e);
|
Slog.w(TAG, "Couldn't get current user ID; guessing it's 0", e);
|
||||||
}
|
}
|
||||||
|
@@ -243,7 +243,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
sb.append("Intent(pkg=").append(is.getCreatorPackage());
|
sb.append("Intent(pkg=").append(is.getCreatorPackage());
|
||||||
try {
|
try {
|
||||||
final boolean isActivity =
|
final boolean isActivity =
|
||||||
ActivityManagerNative.getDefault().isIntentSenderAnActivity(is.getTarget());
|
ActivityManager.getService().isIntentSenderAnActivity(is.getTarget());
|
||||||
if (isActivity) sb.append(" (activity)");
|
if (isActivity) sb.append(" (activity)");
|
||||||
} catch (RemoteException ex) {}
|
} catch (RemoteException ex) {}
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package com.android.settings.users;
|
package com.android.settings.users;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
@@ -681,7 +681,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().switchUser(UserHandle.USER_SYSTEM);
|
ActivityManager.getService().switchUser(UserHandle.USER_SYSTEM);
|
||||||
getContext().getSystemService(UserManager.class).removeUser(UserHandle.myUserId());
|
getContext().getSystemService(UserManager.class).removeUser(UserHandle.myUserId());
|
||||||
} catch (RemoteException re) {
|
} catch (RemoteException re) {
|
||||||
Log.e(TAG, "Unable to remove self user");
|
Log.e(TAG, "Unable to remove self user");
|
||||||
@@ -724,7 +724,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
private void switchUserNow(int userId) {
|
private void switchUserNow(int userId) {
|
||||||
try {
|
try {
|
||||||
ActivityManagerNative.getDefault().switchUser(userId);
|
ActivityManager.getService().switchUser(userId);
|
||||||
} catch (RemoteException re) {
|
} catch (RemoteException re) {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.tests;
|
package com.android.settings.tests;
|
||||||
|
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -47,12 +47,12 @@ public class SettingsRestoreAfterCloseTest {
|
|||||||
.ALWAYS_FINISH_ACTIVITIES, 0)
|
.ALWAYS_FINISH_ACTIVITIES, 0)
|
||||||
!= 0;
|
!= 0;
|
||||||
|
|
||||||
ActivityManagerNative.getDefault().setAlwaysFinish(true);
|
ActivityManager.getService().setAlwaysFinish(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
ActivityManagerNative.getDefault().setAlwaysFinish(mAlwaysFinish);
|
ActivityManager.getService().setAlwaysFinish(mAlwaysFinish);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user