diff options
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 184 | ||||
-rw-r--r-- | cmds/content/src/com/android/commands/content/Content.java | 26 | ||||
-rw-r--r-- | cmds/dpm/src/com/android/commands/dpm/Dpm.java | 18 | ||||
-rwxr-xr-x | cmds/input/input | 2 | ||||
-rw-r--r-- | cmds/media/src/com/android/commands/media/Media.java | 1 | ||||
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 1 | ||||
-rw-r--r-- | cmds/settings/src/com/android/commands/settings/SettingsCmd.java | 24 | ||||
-rw-r--r-- | cmds/svc/src/com/android/commands/svc/DataCommand.java | 2 | ||||
-rw-r--r-- | cmds/svc/src/com/android/commands/svc/WifiCommand.java | 2 | ||||
-rw-r--r-- | cmds/uiautomator/library/Android.mk | 1 |
10 files changed, 215 insertions, 46 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 2ea1d4d..bc0c451 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -44,7 +44,6 @@ import android.net.Uri; import android.os.Binder; import android.os.Build; import android.os.Bundle; -import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.SELinux; @@ -132,10 +131,13 @@ public class Am extends BaseCommand { " am stack start <DISPLAY_ID> <INTENT>\n" + " am stack movetask <TASK_ID> <STACK_ID> [true|false]\n" + " am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + + " am stack split <STACK_ID> <v|h> [INTENT]\n" + " am stack list\n" + " am stack info <STACK_ID>\n" + - " am lock-task <TASK_ID>\n" + - " am lock-task stop\n" + + " am task lock <TASK_ID>\n" + + " am task lock stop\n" + + " am task resizeable <TASK_ID> [true|false]\n" + + " am task resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am get-config\n" + "\n" + "am start: start an Activity. Options are:\n" + @@ -244,13 +246,28 @@ public class Am extends BaseCommand { "am stack movetask: move <TASK_ID> from its current stack to the top (true) or" + " bottom (false) of <STACK_ID>.\n" + "\n" + - "am stack resize: change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>.\n" + + "am stack resize: change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>" + + ".\n" + + "\n" + + "am stack split: split <STACK_ID> into 2 stacks <v>ertically or <h>orizontally\n" + + " starting the new stack with [INTENT] if specified. If [INTENT] isn't\n" + + " specified and the current stack has more than one task, then the top task\n" + + " of the current task will be moved to the new stack. Command will also force\n" + + " all current tasks in both stacks to be resizeable.\n" + "\n" + "am stack list: list all of the activity stacks and their sizes.\n" + "\n" + "am stack info: display the information about activity stack <STACK_ID>.\n" + "\n" + - "am lock-task: bring <TASK_ID> to the front and don't allow other tasks to run\n" + + "am task lock: bring <TASK_ID> to the front and don't allow other tasks to run\n" + + "\n" + + "am task lock stop: end the current task lock\n" + + "\n" + + "am task resizeable: change if <TASK_ID> is resizeable (true) or not (false).\n" + + "\n" + + "am task resize: makes sure <TASK_ID> is in a stack with the specified bounds.\n" + + " Forces the task to be resizeable and creates a stack if no existing stack\n" + + " has the specified bounds.\n" + "\n" + "am get-config: retrieve the configuration and any recent configurations\n" + " of the device\n" + @@ -351,8 +368,8 @@ public class Am extends BaseCommand { runStopUser(); } else if (op.equals("stack")) { runStack(); - } else if (op.equals("lock-task")) { - runLockTask(); + } else if (op.equals("task")) { + runTask(); } else if (op.equals("get-config")) { runGetConfig(); } else { @@ -1682,6 +1699,8 @@ public class Am extends BaseCommand { runStackList(); } else if (op.equals("info")) { runStackInfo(); + } else if (op.equals("split")) { + runStackSplit(); } else { showError("Error: unknown command '" + op + "'"); return; @@ -1694,10 +1713,10 @@ public class Am extends BaseCommand { Intent intent = makeIntent(UserHandle.USER_CURRENT); try { - IBinder homeActivityToken = mAm.getHomeActivityToken(); - IActivityContainer container = mAm.createActivityContainer(homeActivityToken, null); - container.attachToDisplay(displayId); - container.startActivity(intent); + IActivityContainer container = mAm.createStackOnDisplay(displayId); + if (container != null) { + container.startActivity(intent); + } } catch (RemoteException e) { } } @@ -1727,17 +1746,14 @@ public class Am extends BaseCommand { private void runStackResize() throws Exception { String stackIdStr = nextArgRequired(); int stackId = Integer.valueOf(stackIdStr); - String leftStr = nextArgRequired(); - int left = Integer.valueOf(leftStr); - String topStr = nextArgRequired(); - int top = Integer.valueOf(topStr); - String rightStr = nextArgRequired(); - int right = Integer.valueOf(rightStr); - String bottomStr = nextArgRequired(); - int bottom = Integer.valueOf(bottomStr); + final Rect bounds = getBounds(); + if (bounds == null) { + System.err.println("Error: invalid input bounds"); + return; + } try { - mAm.resizeStack(stackId, new Rect(left, top, right, bottom)); + mAm.resizeStack(stackId, bounds); } catch (RemoteException e) { } } @@ -1762,7 +1778,79 @@ public class Am extends BaseCommand { } } - private void runLockTask() throws Exception { + private void runStackSplit() throws Exception { + final int stackId = Integer.valueOf(nextArgRequired()); + final String splitDirection = nextArgRequired(); + Intent intent = null; + try { + intent = makeIntent(UserHandle.USER_CURRENT); + } catch (IllegalArgumentException e) { + // no intent supplied. + } + + try { + final StackInfo currentStackInfo = mAm.getStackInfo(stackId); + // Calculate bounds for new and current stack. + final Rect currentStackBounds = new Rect(currentStackInfo.bounds); + final Rect newStackBounds = new Rect(currentStackInfo.bounds); + if ("v".equals(splitDirection)) { + currentStackBounds.right = newStackBounds.left = currentStackInfo.bounds.centerX(); + } else if ("h".equals(splitDirection)) { + currentStackBounds.bottom = newStackBounds.top = currentStackInfo.bounds.centerY(); + } else { + showError("Error: unknown split direction '" + splitDirection + "'"); + return; + } + + // Create new stack + IActivityContainer container = mAm.createStackOnDisplay(currentStackInfo.displayId); + if (container == null) { + showError("Error: Unable to create new stack..."); + } + + final int newStackId = container.getStackId(); + + if (intent != null) { + container.startActivity(intent); + } else if (currentStackInfo.taskIds != null && currentStackInfo.taskIds.length > 1) { + // Move top task over to new stack + mAm.moveTaskToStack(currentStackInfo.taskIds[currentStackInfo.taskIds.length - 1], + newStackId, true); + } + + final StackInfo newStackInfo = mAm.getStackInfo(newStackId); + + // Make all tasks in the stacks resizeable. + for (int taskId : currentStackInfo.taskIds) { + mAm.setTaskResizeable(taskId, true); + } + + for (int taskId : newStackInfo.taskIds) { + mAm.setTaskResizeable(taskId, true); + } + + // Resize stacks + mAm.resizeStack(currentStackInfo.stackId, currentStackBounds); + mAm.resizeStack(newStackInfo.stackId, newStackBounds); + } catch (RemoteException e) { + } + } + + private void runTask() throws Exception { + String op = nextArgRequired(); + if (op.equals("lock")) { + runTaskLock(); + } else if (op.equals("resizeable")) { + runTaskResizeable(); + } else if (op.equals("resize")) { + runTaskResize(); + } else { + showError("Error: unknown command '" + op + "'"); + return; + } + } + + private void runTaskLock() throws Exception { String taskIdStr = nextArgRequired(); try { if (taskIdStr.equals("stop")) { @@ -1777,6 +1865,32 @@ public class Am extends BaseCommand { } } + private void runTaskResizeable() throws Exception { + final String taskIdStr = nextArgRequired(); + final int taskId = Integer.valueOf(taskIdStr); + final String resizeableStr = nextArgRequired(); + final boolean resizeable = Boolean.valueOf(resizeableStr); + + try { + mAm.setTaskResizeable(taskId, resizeable); + } catch (RemoteException e) { + } + } + + private void runTaskResize() throws Exception { + final String taskIdStr = nextArgRequired(); + final int taskId = Integer.valueOf(taskIdStr); + final Rect bounds = getBounds(); + if (bounds == null) { + System.err.println("Error: invalid input bounds"); + return; + } + try { + mAm.resizeTask(taskId, bounds); + } catch (RemoteException e) { + } + } + private List<Configuration> getRecentConfigurations(int days) { IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService( Context.USAGE_STATS_SERVICE)); @@ -1873,4 +1987,32 @@ public class Am extends BaseCommand { } return fd; } + + private Rect getBounds() { + String leftStr = nextArgRequired(); + int left = Integer.valueOf(leftStr); + String topStr = nextArgRequired(); + int top = Integer.valueOf(topStr); + String rightStr = nextArgRequired(); + int right = Integer.valueOf(rightStr); + String bottomStr = nextArgRequired(); + int bottom = Integer.valueOf(bottomStr); + if (left < 0) { + System.err.println("Error: bad left arg: " + leftStr); + return null; + } + if (top < 0) { + System.err.println("Error: bad top arg: " + topStr); + return null; + } + if (right <= 0) { + System.err.println("Error: bad right arg: " + rightStr); + return null; + } + if (bottom <= 0) { + System.err.println("Error: bad bottom arg: " + bottomStr); + return null; + } + return new Rect(left, top, right, bottom); + } } diff --git a/cmds/content/src/com/android/commands/content/Content.java b/cmds/content/src/com/android/commands/content/Content.java index bd34a9c..c0ed893 100644 --- a/cmds/content/src/com/android/commands/content/Content.java +++ b/cmds/content/src/com/android/commands/content/Content.java @@ -27,6 +27,7 @@ import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.ParcelFileDescriptor; +import android.os.Process; import android.os.UserHandle; import android.text.TextUtils; @@ -426,6 +427,22 @@ public class Content { } } + public static String resolveCallingPackage() { + switch (Process.myUid()) { + case Process.ROOT_UID: { + return "root"; + } + + case Process.SHELL_UID: { + return "com.android.shell"; + } + + default: { + return null; + } + } + } + protected abstract void onExecute(IContentProvider provider) throws Exception; } @@ -439,7 +456,7 @@ public class Content { @Override public void onExecute(IContentProvider provider) throws Exception { - provider.insert(null, mUri, mContentValues); + provider.insert(resolveCallingPackage(), mUri, mContentValues); } } @@ -453,7 +470,7 @@ public class Content { @Override public void onExecute(IContentProvider provider) throws Exception { - provider.delete(null, mUri, mWhere, null); + provider.delete(resolveCallingPackage(), mUri, mWhere, null); } } @@ -532,7 +549,8 @@ public class Content { @Override public void onExecute(IContentProvider provider) throws Exception { - Cursor cursor = provider.query(null, mUri, mProjection, mWhere, null, mSortOrder, null); + Cursor cursor = provider.query(resolveCallingPackage(), mUri, mProjection, mWhere, + null, mSortOrder, null); if (cursor == null) { System.out.println("No result found."); return; @@ -594,7 +612,7 @@ public class Content { @Override public void onExecute(IContentProvider provider) throws Exception { - provider.update(null, mUri, mContentValues, mWhere, null); + provider.update(resolveCallingPackage(), mUri, mContentValues, mWhere, null); } } diff --git a/cmds/dpm/src/com/android/commands/dpm/Dpm.java b/cmds/dpm/src/com/android/commands/dpm/Dpm.java index 781fb96..3d86ac1 100644 --- a/cmds/dpm/src/com/android/commands/dpm/Dpm.java +++ b/cmds/dpm/src/com/android/commands/dpm/Dpm.java @@ -52,7 +52,7 @@ public final class Dpm extends BaseCommand { "usage: dpm [subcommand] [options]\n" + "usage: dpm set-active-admin [ --user <USER_ID> ] <COMPONENT>\n" + "usage: dpm set-device-owner <COMPONENT>\n" + - "usage: dpm set-profile-owner <COMPONENT> <USER_ID>\n" + + "usage: dpm set-profile-owner [ --user <USER_ID> ] <COMPONENT>\n" + "\n" + "dpm set-active-admin: Sets the given component as active admin" + " for an existing user.\n" + @@ -125,23 +125,21 @@ public final class Dpm extends BaseCommand { } private void runSetProfileOwner() throws RemoteException { - // To be refactored later to use parseArgs(boolean). Currently in use by existing tests. - ComponentName component = parseComponentName(nextArgRequired()); - int userId = parseInt(nextArgRequired()); - mDevicePolicyManager.setActiveAdmin(component, true /*refreshing*/, userId); + parseArgs(true); + mDevicePolicyManager.setActiveAdmin(mComponent, true /*refreshing*/, mUserId); try { - if (!mDevicePolicyManager.setProfileOwner(component, "" /*ownerName*/, userId)) { - throw new RuntimeException("Can't set component " + component.toShortString() + - " as profile owner for user " + userId); + if (!mDevicePolicyManager.setProfileOwner(mComponent, "" /*ownerName*/, mUserId)) { + throw new RuntimeException("Can't set component " + mComponent.toShortString() + + " as profile owner for user " + mUserId); } } catch (Exception e) { // Need to remove the admin that we just added. - mDevicePolicyManager.removeActiveAdmin(component, userId); + mDevicePolicyManager.removeActiveAdmin(mComponent, mUserId); throw e; } System.out.println("Success: Active admin and profile owner set to " - + component.toShortString() + " for user " + userId); + + mComponent.toShortString() + " for user " + mUserId); } private ComponentName parseComponentName(String component) { diff --git a/cmds/input/input b/cmds/input/input index fa9dced..7f1a18e 100755 --- a/cmds/input/input +++ b/cmds/input/input @@ -3,5 +3,5 @@ # base=/system export CLASSPATH=$base/framework/input.jar -exec app_process $base/bin com.android.commands.input.Input $* +exec app_process $base/bin com.android.commands.input.Input "$@" diff --git a/cmds/media/src/com/android/commands/media/Media.java b/cmds/media/src/com/android/commands/media/Media.java index 6a8fb05..d7f23cb 100644 --- a/cmds/media/src/com/android/commands/media/Media.java +++ b/cmds/media/src/com/android/commands/media/Media.java @@ -24,7 +24,6 @@ import android.media.MediaMetadata; import android.media.session.ISessionController; import android.media.session.ISessionControllerCallback; import android.media.session.ISessionManager; -import android.media.session.MediaController; import android.media.session.ParcelableVolumeInfo; import android.media.session.PlaybackState; import android.os.Bundle; diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 7a01701..c48a618 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -48,7 +48,6 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.IUserManager; -import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; diff --git a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java index e6847a9..a31b150 100644 --- a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java +++ b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java @@ -24,12 +24,12 @@ import android.net.Uri; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; +import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.provider.Settings; public final class SettingsCmd { - static final String TAG = "settings"; enum CommandVerb { UNSPECIFIED, @@ -188,7 +188,7 @@ public final class SettingsCmd { try { Bundle arg = new Bundle(); arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle); - Bundle b = provider.call(null, callGetCommand, key, arg); + Bundle b = provider.call(resolveCallingPackage(), callGetCommand, key, arg); if (b != null) { result = b.getPairValue(); } @@ -213,7 +213,7 @@ public final class SettingsCmd { Bundle arg = new Bundle(); arg.putString(Settings.NameValueTable.VALUE, value); arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle); - provider.call(null, callPutCommand, key, arg); + provider.call(resolveCallingPackage(), callPutCommand, key, arg); } catch (RemoteException e) { System.err.println("Can't set key " + key + " in " + table + " for user " + userHandle); } @@ -232,7 +232,7 @@ public final class SettingsCmd { int num = 0; try { - num = provider.delete(null, targetUri, null, null); + num = provider.delete(resolveCallingPackage(), targetUri, null, null); } catch (RemoteException e) { System.err.println("Can't clear key " + key + " in " + table + " for user " + userHandle); @@ -247,4 +247,20 @@ public final class SettingsCmd { System.err.println("\n'namespace' is one of {system, secure, global}, case-insensitive"); System.err.println("If '--user NUM' is not given, the operations are performed on the owner user."); } + + public static String resolveCallingPackage() { + switch (android.os.Process.myUid()) { + case Process.ROOT_UID: { + return "root"; + } + + case Process.SHELL_UID: { + return "com.android.shell"; + } + + default: { + return null; + } + } + } } diff --git a/cmds/svc/src/com/android/commands/svc/DataCommand.java b/cmds/svc/src/com/android/commands/svc/DataCommand.java index 406e33b..35510cf 100644 --- a/cmds/svc/src/com/android/commands/svc/DataCommand.java +++ b/cmds/svc/src/com/android/commands/svc/DataCommand.java @@ -18,8 +18,6 @@ package com.android.commands.svc; import android.os.ServiceManager; import android.os.RemoteException; -import android.net.IConnectivityManager; -import android.net.ConnectivityManager; import android.content.Context; import com.android.internal.telephony.ITelephony; diff --git a/cmds/svc/src/com/android/commands/svc/WifiCommand.java b/cmds/svc/src/com/android/commands/svc/WifiCommand.java index 39f0e35..94214ff 100644 --- a/cmds/svc/src/com/android/commands/svc/WifiCommand.java +++ b/cmds/svc/src/com/android/commands/svc/WifiCommand.java @@ -19,8 +19,6 @@ package com.android.commands.svc; import android.os.ServiceManager; import android.os.RemoteException; import android.net.wifi.IWifiManager; -import android.net.IConnectivityManager; -import android.net.ConnectivityManager; import android.content.Context; public class WifiCommand extends Svc.Command { diff --git a/cmds/uiautomator/library/Android.mk b/cmds/uiautomator/library/Android.mk index 7cc0884..2123f25 100644 --- a/cmds/uiautomator/library/Android.mk +++ b/cmds/uiautomator/library/Android.mk @@ -65,6 +65,7 @@ LOCAL_SOURCE_FILES_ALL_GENERATED := true include $(BUILD_STATIC_JAVA_LIBRARY) # Make sure to run droiddoc first to generate the stub source files. $(full_classes_compiled_jar) : $(uiautomator_stubs_stamp) +$(built_dex_intermediate) : $(uiautomator_stubs_stamp) uiautomator_stubs_jar := $(full_classes_compiled_jar) ############################################### |