use of com.android.server.NativeDaemonConnector.Command in project android_frameworks_base by ParanoidAndroid.
the class MountService method destroySecureContainer.
public int destroySecureContainer(String id, boolean force) {
validatePermission(android.Manifest.permission.ASEC_DESTROY);
waitForReady();
warnOnNotMounted();
/*
* Force a GC to make sure AssetManagers in other threads of the
* system_server are cleaned up. We have to do this since AssetManager
* instances are kept as a WeakReference and it's possible we have files
* open on the external storage.
*/
Runtime.getRuntime().gc();
int rc = StorageResultCode.OperationSucceeded;
try {
final Command cmd = new Command("asec", "destroy", id);
if (force) {
cmd.appendArg("force");
}
mConnector.execute(cmd);
} catch (NativeDaemonConnectorException e) {
int code = e.getCode();
if (code == VoldResponseCode.OpFailedStorageBusy) {
rc = StorageResultCode.OperationFailedStorageBusy;
} else {
rc = StorageResultCode.OperationFailedInternalError;
}
}
if (rc == StorageResultCode.OperationSucceeded) {
synchronized (mAsecMountSet) {
if (mAsecMountSet.contains(id)) {
mAsecMountSet.remove(id);
}
}
}
return rc;
}
use of com.android.server.NativeDaemonConnector.Command in project android_frameworks_base by ParanoidAndroid.
the class NetworkManagementService method setInterfaceConfig.
@Override
public void setInterfaceConfig(String iface, InterfaceConfiguration cfg) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
LinkAddress linkAddr = cfg.getLinkAddress();
if (linkAddr == null || linkAddr.getAddress() == null) {
throw new IllegalStateException("Null LinkAddress given");
}
final Command cmd = new Command("interface", "setcfg", iface, linkAddr.getAddress().getHostAddress(), linkAddr.getNetworkPrefixLength());
for (String flag : cfg.getFlags()) {
cmd.appendArg(flag);
}
try {
mConnector.execute(cmd);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
}
use of com.android.server.NativeDaemonConnector.Command in project android_frameworks_base by ParanoidAndroid.
the class NetworkManagementService method setDnsServersForInterface.
@Override
public void setDnsServersForInterface(String iface, String[] servers, String domains) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
final Command cmd = new Command("resolver", "setifdns", iface, (domains == null ? "" : domains));
for (String s : servers) {
InetAddress a = NetworkUtils.numericToInetAddress(s);
if (a.isAnyLocalAddress() == false) {
cmd.appendArg(a.getHostAddress());
}
}
try {
mConnector.execute(cmd);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
}
use of com.android.server.NativeDaemonConnector.Command in project android_frameworks_base by ParanoidAndroid.
the class NetworkManagementService method modifyRoute.
private void modifyRoute(String interfaceName, String action, RouteInfo route, String type) {
final Command cmd = new Command("interface", "route", action, interfaceName, type);
// create triplet: dest-ip-addr prefixlength gateway-ip-addr
final LinkAddress la = route.getDestination();
cmd.appendArg(la.getAddress().getHostAddress());
cmd.appendArg(la.getNetworkPrefixLength());
if (route.getGateway() == null) {
if (la.getAddress() instanceof Inet4Address) {
cmd.appendArg("0.0.0.0");
} else {
cmd.appendArg("::0");
}
} else {
cmd.appendArg(route.getGateway().getHostAddress());
}
try {
mConnector.execute(cmd);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
}
use of com.android.server.NativeDaemonConnector.Command in project platform_frameworks_base by android.
the class MountService method unmountSecureContainer.
public int unmountSecureContainer(String id, boolean force) {
enforcePermission(android.Manifest.permission.ASEC_MOUNT_UNMOUNT);
waitForReady();
warnOnNotMounted();
synchronized (mAsecMountSet) {
if (!mAsecMountSet.contains(id)) {
return StorageResultCode.OperationFailedStorageNotMounted;
}
}
/*
* Force a GC to make sure AssetManagers in other threads of the
* system_server are cleaned up. We have to do this since AssetManager
* instances are kept as a WeakReference and it's possible we have files
* open on the external storage.
*/
Runtime.getRuntime().gc();
int rc = StorageResultCode.OperationSucceeded;
try {
final Command cmd = new Command("asec", "unmount", id);
if (force) {
cmd.appendArg("force");
}
mConnector.execute(cmd);
} catch (NativeDaemonConnectorException e) {
int code = e.getCode();
if (code == VoldResponseCode.OpFailedStorageBusy) {
rc = StorageResultCode.OperationFailedStorageBusy;
} else {
rc = StorageResultCode.OperationFailedInternalError;
}
}
if (rc == StorageResultCode.OperationSucceeded) {
synchronized (mAsecMountSet) {
mAsecMountSet.remove(id);
}
}
return rc;
}
Aggregations