diff --git a/client/client/build.gradle b/client/client/build.gradle
index 8e521781..5ebc5687 100644
--- a/client/client/build.gradle
+++ b/client/client/build.gradle
@@ -775,6 +775,7 @@ dependencies {
compile 'commons-net:commons-net:3.3'
compile "org.java-websocket:Java-WebSocket:1.3.0"
compile "org.apache.commons:commons-lang3:3.6"
+ compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
diff --git a/client/client/src/main/AndroidManifest.xml b/client/client/src/main/AndroidManifest.xml
index f2bf5370..a6e61583 100644
--- a/client/client/src/main/AndroidManifest.xml
+++ b/client/client/src/main/AndroidManifest.xml
@@ -32,7 +32,6 @@
-
diff --git a/client/client/src/main/java/org/wso2/iot/agent/AgentApplication.java b/client/client/src/main/java/org/wso2/iot/agent/AgentApplication.java
index 4bdbc002..bfc51ba1 100644
--- a/client/client/src/main/java/org/wso2/iot/agent/AgentApplication.java
+++ b/client/client/src/main/java/org/wso2/iot/agent/AgentApplication.java
@@ -19,10 +19,10 @@
package org.wso2.iot.agent;
import android.app.AlarmManager;
-import android.app.Application;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
+import android.support.multidex.MultiDexApplication;
import android.util.Log;
import com.splunk.mint.Mint;
@@ -31,7 +31,7 @@
import org.wso2.iot.agent.utils.CommonUtils;
import org.wso2.iot.agent.utils.Constants;
-public class AgentApplication extends Application {
+public class AgentApplication extends MultiDexApplication {
// Configs
private int requestCode = 0;
diff --git a/client/client/src/main/java/org/wso2/iot/agent/api/ApplicationManager.java b/client/client/src/main/java/org/wso2/iot/agent/api/ApplicationManager.java
index 0752bfae..15941cd3 100644
--- a/client/client/src/main/java/org/wso2/iot/agent/api/ApplicationManager.java
+++ b/client/client/src/main/java/org/wso2/iot/agent/api/ApplicationManager.java
@@ -18,7 +18,6 @@
package org.wso2.iot.agent.api;
-import android.annotation.TargetApi;
import android.app.DownloadManager;
import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
@@ -290,8 +289,7 @@ public String getAppNameFromPackage(String packageName) {
public boolean isPackageInstalled(String packagename) {
try {
- PackageInfo packageInfo = packageManager.
- getPackageInfo(packagename, 0);
+ PackageInfo packageInfo = packageManager.getPackageInfo(packagename, 0);
if (packageInfo != null) {
return true;
}
@@ -318,15 +316,15 @@ private void triggerInstallation(Uri fileUri) {
*
* @param fileUri - File URI should be passed in as a String.
*/
- public void startInstallerIntent(Uri fileUri) {
+ private void startInstallerIntent(Uri fileUri) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
policyManager.isDeviceOwnerApp(Constants.AGENT_PACKAGE)) {
Uri packageFileUri;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
packageFileUri = convertContentUriToFileUri(fileUri);
- else
+ } else {
packageFileUri = fileUri;
-
+ }
installPackage(packageFileUri);
} else {
boolean isUnknownSourcesDisallowed = Preference.getBoolean(context,
@@ -337,18 +335,16 @@ public void startInstallerIntent(Uri fileUri) {
intent.setDataAndType(fileUri, resources.getString(R.string.application_mgr_mime));
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(intent);
-
} else {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(fileUri, resources.getString(R.string.application_mgr_mime));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
-
}
}
- public Uri convertContentUriToFileUri(Uri contentUri) {
+ private Uri convertContentUriToFileUri(Uri contentUri) {
String uriString = contentUri.toString();
uriString = "file://" + Environment.getExternalStorageDirectory() +
uriString.replace("content://org.wso2.iot.agent.provider/external_files", "");
@@ -356,7 +352,7 @@ public Uri convertContentUriToFileUri(Uri contentUri) {
}
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
- public boolean installPackage(Uri fileUri) {
+ private boolean installPackage(Uri fileUri) {
InputStream in;
OutputStream out;
@@ -537,10 +533,11 @@ public void setupAppDownload(String url, int operationId, String operationCode)
public void uninstallApplication(String packageName, String schedule) throws AndroidAgentException {
String packageUriString = packageName;
if (packageName != null) {
- if (!packageName.contains(resources.getString(R.string.application_package_prefix)))
+ if (!packageName.contains(resources.getString(R.string.application_package_prefix))) {
packageUriString = resources.getString(R.string.application_package_prefix) + packageName;
- else
+ } else {
packageName = packageName.replace(resources.getString(R.string.application_package_prefix), "");
+ }
}
if (!this.isPackageInstalled(packageName)) {
@@ -564,10 +561,11 @@ public void uninstallApplication(String packageName, String schedule) throws And
CommonUtils.callSystemApp(context, Constants.Operation.SILENT_UNINSTALL_APPLICATION, "", packageUriString);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
policyManager.isDeviceOwnerApp(Constants.AGENT_PACKAGE)) {
- if (silentlyUninstallApplication(packageName))
+ if (silentlyUninstallApplication(packageName)) {
Preference.putString(context, context.getResources().getString(R.string.app_uninstall_status), APP_STATE_UNINSTALLED);
- else
+ } else {
Preference.putString(context, context.getResources().getString(R.string.app_uninstall_status), APP_STATE_UNINSTALLED_FAILED);
+ }
Preference.putString(context, context.getResources().getString(R.string.app_uninstall_failed_message), null);
} else {
Preference.putString(context, context.getResources().getString(R.string.app_uninstall_status), APP_STATE_UNINSTALLED);
@@ -585,7 +583,7 @@ public void uninstallApplication(String packageName, String schedule) throws And
* @param packageName - Application package name should be passed in as a String.
*/
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
- public boolean silentlyUninstallApplication(String packageName) {
+ private boolean silentlyUninstallApplication(String packageName) {
PackageInstaller.SessionParams params = new PackageInstaller.SessionParams(
PackageInstaller.SessionParams.MODE_FULL_INSTALL);
params.setAppPackageName(packageName);
diff --git a/client/client/src/main/java/org/wso2/iot/agent/services/operation/OperationManager.java b/client/client/src/main/java/org/wso2/iot/agent/services/operation/OperationManager.java
index 9f8e5966..1985265a 100644
--- a/client/client/src/main/java/org/wso2/iot/agent/services/operation/OperationManager.java
+++ b/client/client/src/main/java/org/wso2/iot/agent/services/operation/OperationManager.java
@@ -32,6 +32,7 @@
import android.os.Build;
import android.os.PowerManager;
import android.preference.PreferenceManager;
+import android.support.annotation.RequiresApi;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
@@ -1187,6 +1188,7 @@ public void processRemoteShell(org.wso2.iot.agent.beans.Operation operation) thr
* @throws TransportHandlerException - Throws when session connection has an error
* @throws JSONException - Throws when error occurs while parsing the payload
*/
+ @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void screenCapture(org.wso2.iot.agent.beans.Operation operation) throws TransportHandlerException,
JSONException {
String action;
@@ -1253,6 +1255,7 @@ public void screenCapture(org.wso2.iot.agent.beans.Operation operation) throws T
* @throws TransportHandlerException - Throws when session connection has an error
* @throws JSONException - Throws when error occurs while parsing the payload
*/
+ @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void processInputInject(org.wso2.iot.agent.beans.Operation operation) throws TransportHandlerException,
JSONException {
if (Constants.SYSTEM_APP_ENABLED && ScreenSharingService.isScreenShared) {