use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.
the class Pm method displayPackageFilePath.
/**
* Displays the package file for a package.
* @param pckg
*/
private void displayPackageFilePath(String pckg) {
try {
PackageInfo info = mPm.getPackageInfo(pckg, 0, 0);
if (info != null && info.applicationInfo != null) {
System.out.print("package:");
System.out.println(info.applicationInfo.sourceDir);
}
} catch (RemoteException e) {
System.err.println(e.toString());
System.err.println(PM_NOT_RUNNING_ERR);
}
}
use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.
the class Pm method runListPackages.
/**
* Lists all the installed packages.
*/
private void runListPackages(boolean showApplicationPackage) {
int getFlags = 0;
boolean listDisabled = false, listEnabled = false;
boolean listSystem = false, listThirdParty = false;
boolean listInstaller = false;
int userId = UserHandle.USER_OWNER;
try {
String opt;
while ((opt = nextOption()) != null) {
if (opt.equals("-l")) {
// old compat
} else if (opt.equals("-lf")) {
showApplicationPackage = true;
} else if (opt.equals("-f")) {
showApplicationPackage = true;
} else if (opt.equals("-d")) {
listDisabled = true;
} else if (opt.equals("-e")) {
listEnabled = true;
} else if (opt.equals("-s")) {
listSystem = true;
} else if (opt.equals("-3")) {
listThirdParty = true;
} else if (opt.equals("-i")) {
listInstaller = true;
} else if (opt.equals("--user")) {
userId = Integer.parseInt(nextArg());
} else if (opt.equals("-u")) {
getFlags |= PackageManager.GET_UNINSTALLED_PACKAGES;
} else {
System.err.println("Error: Unknown option: " + opt);
return;
}
}
} catch (RuntimeException ex) {
System.err.println("Error: " + ex.toString());
return;
}
String filter = nextArg();
try {
final List<PackageInfo> packages = getInstalledPackages(mPm, getFlags, userId);
int count = packages.size();
for (int p = 0; p < count; p++) {
PackageInfo info = packages.get(p);
if (filter != null && !info.packageName.contains(filter)) {
continue;
}
final boolean isSystem = (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
if ((!listDisabled || !info.applicationInfo.enabled) && (!listEnabled || info.applicationInfo.enabled) && (!listSystem || isSystem) && (!listThirdParty || !isSystem)) {
System.out.print("package:");
if (showApplicationPackage) {
System.out.print(info.applicationInfo.sourceDir);
System.out.print("=");
}
System.out.print(info.packageName);
if (listInstaller) {
System.out.print(" installer=");
System.out.print(mPm.getInstallerPackageName(info.packageName));
}
System.out.println();
}
}
} catch (RemoteException e) {
System.err.println(e.toString());
System.err.println(PM_NOT_RUNNING_ERR);
}
}
use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.
the class SettingsCmd method putForUser.
void putForUser(IContentProvider provider, int userHandle, final String table, final String key, final String value) {
final String callPutCommand;
if ("system".equals(table))
callPutCommand = Settings.CALL_METHOD_PUT_SYSTEM;
else if ("secure".equals(table))
callPutCommand = Settings.CALL_METHOD_PUT_SECURE;
else if ("global".equals(table))
callPutCommand = Settings.CALL_METHOD_PUT_GLOBAL;
else {
System.err.println("Invalid table; no put performed");
return;
}
try {
Bundle arg = new Bundle();
arg.putString(Settings.NameValueTable.VALUE, value);
arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle);
provider.call(null, callPutCommand, key, arg);
} catch (RemoteException e) {
System.err.println("Can't set key " + key + " in " + table + " for user " + userHandle);
}
}
use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.
the class DataCommand method run.
public void run(String[] args) {
boolean validCommand = false;
if (args.length >= 2) {
boolean flag = false;
if ("enable".equals(args[1])) {
flag = true;
validCommand = true;
} else if ("disable".equals(args[1])) {
flag = false;
validCommand = true;
} else if ("prefer".equals(args[1])) {
IConnectivityManager connMgr = IConnectivityManager.Stub.asInterface(ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
try {
connMgr.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);
} catch (RemoteException e) {
System.err.println("Failed to set preferred network: " + e);
}
return;
}
if (validCommand) {
ITelephony phoneMgr = ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
try {
if (flag) {
phoneMgr.enableDataConnectivity();
} else
phoneMgr.disableDataConnectivity();
} catch (RemoteException e) {
System.err.println("Mobile data operation failed: " + e);
}
return;
}
}
System.err.println(longHelp());
}
use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.
the class Wm method runDisplaySize.
private void runDisplaySize() throws Exception {
String size = nextArg();
int w, h;
if (size == null) {
Point initialSize = new Point();
Point baseSize = new Point();
try {
mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
mWm.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize);
System.out.println("Physical size: " + initialSize.x + "x" + initialSize.y);
if (!initialSize.equals(baseSize)) {
System.out.println("Override size: " + baseSize.x + "x" + baseSize.y);
}
} catch (RemoteException e) {
}
return;
} else if ("reset".equals(size)) {
w = h = -1;
} else {
int div = size.indexOf('x');
if (div <= 0 || div >= (size.length() - 1)) {
System.err.println("Error: bad size " + size);
return;
}
String wstr = size.substring(0, div);
String hstr = size.substring(div + 1);
try {
w = Integer.parseInt(wstr);
h = Integer.parseInt(hstr);
} catch (NumberFormatException e) {
System.err.println("Error: bad number " + e);
return;
}
}
try {
if (w >= 0 && h >= 0) {
// TODO(multidisplay): For now Configuration only applies to main screen.
mWm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, w, h);
} else {
mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
}
} catch (RemoteException e) {
}
}
Aggregations