use of org.fdroid.fdroid.privileged.IPrivilegedCallback in project fdroidclient by f-droid.
the class PrivilegedInstaller method installPackageInternal.
@Override
protected void installPackageInternal(final Uri localApkUri, final Uri canonicalUri) {
ServiceConnection mServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
IPrivilegedService privService = IPrivilegedService.Stub.asInterface(service);
IPrivilegedCallback callback = new IPrivilegedCallback.Stub() {
@Override
public void handleResult(String packageName, int returnCode) throws RemoteException {
if (returnCode == INSTALL_SUCCEEDED) {
sendBroadcastInstall(canonicalUri, ACTION_INSTALL_COMPLETE);
} else {
sendBroadcastInstall(canonicalUri, ACTION_INSTALL_INTERRUPTED, "Error " + returnCode + ": " + INSTALL_RETURN_CODES.get(returnCode));
}
}
};
try {
boolean hasPermissions = privService.hasPrivilegedPermissions();
if (!hasPermissions) {
sendBroadcastInstall(canonicalUri, ACTION_INSTALL_INTERRUPTED, context.getString(R.string.system_install_denied_permissions));
return;
}
privService.installPackage(localApkUri, ACTION_INSTALL_REPLACE_EXISTING, null, callback);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
sendBroadcastInstall(canonicalUri, ACTION_INSTALL_INTERRUPTED, "connecting to privileged service failed");
}
}
public void onServiceDisconnected(ComponentName name) {
}
};
Intent serviceIntent = new Intent(PRIVILEGED_EXTENSION_SERVICE_INTENT);
serviceIntent.setPackage(PRIVILEGED_EXTENSION_PACKAGE_NAME);
context.getApplicationContext().bindService(serviceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
}
use of org.fdroid.fdroid.privileged.IPrivilegedCallback in project fdroidclient by f-droid.
the class PrivilegedInstaller method uninstallPackage.
@Override
protected void uninstallPackage() {
ServiceConnection mServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
IPrivilegedService privService = IPrivilegedService.Stub.asInterface(service);
IPrivilegedCallback callback = new IPrivilegedCallback.Stub() {
@Override
public void handleResult(String packageName, int returnCode) throws RemoteException {
if (returnCode == DELETE_SUCCEEDED) {
sendBroadcastUninstall(ACTION_UNINSTALL_COMPLETE);
} else {
sendBroadcastUninstall(ACTION_UNINSTALL_INTERRUPTED, "Error " + returnCode + ": " + UNINSTALL_RETURN_CODES.get(returnCode));
}
}
};
try {
boolean hasPermissions = privService.hasPrivilegedPermissions();
if (!hasPermissions) {
sendBroadcastUninstall(ACTION_UNINSTALL_INTERRUPTED, context.getString(R.string.system_install_denied_permissions));
return;
}
privService.deletePackage(apk.packageName, 0, callback);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
sendBroadcastUninstall(ACTION_UNINSTALL_INTERRUPTED, "connecting to privileged service failed");
}
}
public void onServiceDisconnected(ComponentName name) {
}
};
Intent serviceIntent = new Intent(PRIVILEGED_EXTENSION_SERVICE_INTENT);
serviceIntent.setPackage(PRIVILEGED_EXTENSION_PACKAGE_NAME);
context.getApplicationContext().bindService(serviceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
}
Aggregations