Skip to content

Commit

Permalink
Merge pull request #177 from charithag/master
Browse files Browse the repository at this point in the history
Fix issues with Oreo
  • Loading branch information
charithag authored May 23, 2018
2 parents 88ea71d + 40d835f commit f1bb3ed
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 29 deletions.
2 changes: 1 addition & 1 deletion client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'
}
}

Expand Down
8 changes: 4 additions & 4 deletions client/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {
targetSdkVersion 25
multiDexEnabled true

versionCode 3010033
versionName "3.1.33"
versionCode 3010034
versionName "3.1.34"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -761,7 +761,7 @@ dependencies {
compile 'com.android.support:design:25.4.0'
compile 'commons-io:commons-io:2.5'
compile 'com.google.android.gms:play-services-base:11.8.0'
compile "com.google.android.gms:play-services-location:11.8.0"
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.6.4'
Expand All @@ -773,7 +773,7 @@ dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jcraft:jsch:0.1.54'
compile 'commons-net:commons-net:3.3'
compile "org.java-websocket:Java-WebSocket:1.3.0"
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'
}
Expand Down
2 changes: 1 addition & 1 deletion client/client/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,4 @@
</provider>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.splunk.mint.Mint;

import org.wso2.iot.agent.services.AgentStartupReceiver;
import org.wso2.iot.agent.services.EnrollmentService;
import org.wso2.iot.agent.utils.CommonUtils;
import org.wso2.iot.agent.utils.Constants;
Expand All @@ -51,7 +52,7 @@ requestCode, new Intent(getApplicationContext(), EnrollmentService.class),
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
relaunchDelay, pendingIntent);
} else {
Intent intent = new Intent();
Intent intent = new Intent(AgentApplication.this, AgentStartupReceiver.class);
intent.setAction("org.ws2.iot.agent.APPLICATION_CRASHED");
sendBroadcast(intent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ public void onClick(View v) {
// as mute that can cause a device to go into "do not disturb" will need additional
// permission. Added here as well to support already enrolled devices to optain the
// permission without reenrolling.
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M && !notificationManager
.isNotificationPolicyAccessGranted()) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M
&& !devicePolicyManager.isProfileOwnerApp(Constants.AGENT_PACKAGE)
&& notificationManager != null
&& !notificationManager.isNotificationPolicyAccessGranted()) {
CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
getResources().getString(R.string.dialog_do_not_distrub_title),
getResources().getString(R.string.dialog_do_not_distrub_message),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,10 @@ public void onRequestPermissionsResult(int requestCode,
if (requestCode == PERMISSION_REQUEST) {
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M && !notificationManager
.isNotificationPolicyAccessGranted()) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M
&& !devicePolicyManager.isProfileOwnerApp(Constants.AGENT_PACKAGE)
&& notificationManager != null
&& !notificationManager.isNotificationPolicyAccessGranted()) {
CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
getResources().getString(R.string.dialog_do_not_distrub_title),
getResources().getString(R.string.dialog_do_not_distrub_message),
Expand Down Expand Up @@ -1366,4 +1368,4 @@ public void onAuthenticated(boolean status, int requestCode) {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ private void startInstallerIntent(Uri fileUri) {
private Uri convertContentUriToFileUri(Uri contentUri) {
String uriString = contentUri.toString();
uriString = "file://" + Environment.getExternalStorageDirectory() +
uriString.replace("content://org.wso2.iot.agent.provider/external_files", "");
uriString.replace("content://" + Constants.AGENT_PACKAGE
+ ".provider/external_files", "");
return Uri.parse(uriString);
}

Expand All @@ -367,7 +368,7 @@ private boolean installPackage(Uri fileUri) {
// set params
int sessionId = packageInstaller.createSession(params);
PackageInstaller.Session session = packageInstaller.openSession(sessionId);
out = session.openWrite("WSO2", 0, -1);
out = session.openWrite(Constants.AGENT_PACKAGE, 0, -1);
byte[] buffer = new byte[65536];
int c;
while ((c = in.read(buffer)) != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.wso2.iot.agent.events.beans.EventPayload;
import org.wso2.iot.agent.events.publisher.HttpDataPublisher;
import org.wso2.iot.agent.services.AgentDeviceAdminReceiver;
import org.wso2.iot.agent.services.AgentStartupReceiver;
import org.wso2.iot.agent.services.AppLockService;
import org.wso2.iot.agent.utils.CommonUtils;
import org.wso2.iot.agent.utils.Constants;
Expand Down Expand Up @@ -134,7 +135,7 @@ public void onReceive(Context context, final Intent intent) {
}
if (Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction()) &&
Constants.AGENT_PACKAGE.equals(packageName)) {
Intent broadcastIntent = new Intent();
Intent broadcastIntent = new Intent(context, AgentStartupReceiver.class);
broadcastIntent.setAction(Constants.AGENT_UPDATED_BROADCAST_ACTION);
context.sendBroadcast(broadcastIntent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.wso2.iot.agent.activities.AlreadyRegisteredActivity;
import org.wso2.iot.agent.events.beans.EventPayload;
import org.wso2.iot.agent.events.publisher.HttpDataPublisher;
import org.wso2.iot.agent.services.LocationUpdateReceiver;
import org.wso2.iot.agent.utils.CommonUtils;
import org.wso2.iot.agent.utils.Constants;

Expand Down Expand Up @@ -122,7 +123,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
+ android.os.Build.VERSION.SDK_INT);
}
}
if (Build.VERSION.SDK_INT >= 23
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(this,
Expand Down Expand Up @@ -168,7 +169,7 @@ public void onSuccess(Location location) {
}

private void broadcastLocation(Location location) {
Intent broadcastIntent = new Intent();
Intent broadcastIntent = new Intent(this, LocationUpdateReceiver.class);
broadcastIntent.setAction(Constants.LOCATION_UPDATE_BROADCAST_ACTION);
broadcastIntent.putExtra(Constants.Location.LOCATION, location);
sendBroadcast(broadcastIntent);
Expand All @@ -192,7 +193,7 @@ public void onCreate() {
@Override
public void onDestroy() {
if (isUpdateRequested) {
if (Build.VERSION.SDK_INT >= 23
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(this,
Expand Down Expand Up @@ -222,7 +223,7 @@ public void onDestroy() {
* In this method, it gets the latest location updates from gps/ network.
*/
private void requestLocationUpdates() {
if (Build.VERSION.SDK_INT >= 23
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.wso2.iot.agent.AlertActivity;
import org.wso2.iot.agent.AndroidAgentException;
import org.wso2.iot.agent.R;
import org.wso2.iot.agent.activities.AlreadyRegisteredActivity;
import org.wso2.iot.agent.activities.ScreenShareActivity;
import org.wso2.iot.agent.api.ApplicationManager;
import org.wso2.iot.agent.api.DeviceInfo;
Expand Down Expand Up @@ -880,14 +881,20 @@ public void lockDevice(org.wso2.iot.agent.beans.Operation operation) throws Andr
} else {
operation.setStatus(resources.getString(R.string.operation_value_completed));
resultBuilder.build(operation);
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(context, AlreadyRegisteredActivity.class);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_lock_white_24dp)
.setContentTitle(context.getString(R.string.alert_message))
.setContentText(message)
.setAutoCancel(true)
.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(), 0));
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, mBuilder.build());
.setContentIntent(PendingIntent.getActivity(context, 0, intent, 0));
if (notificationManager != null) {
notificationManager.notify(0, mBuilder.build());
} else {
Log.w(TAG, "Unable to retrieve notification manager.");
}
devicePolicyManager.lockNow();
}

Expand Down Expand Up @@ -1141,7 +1148,6 @@ public void displayNotification(org.wso2.iot.agent.beans.Operation operation) th
*
* @param operation Operation received to start session
* @throws AndroidAgentException Throws when error occur while connecting to session
*
*/
public void connectToRemoteSession(org.wso2.iot.agent.beans.Operation operation) throws AndroidAgentException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,4 +771,4 @@ private String getPermissionConstantValue(String key) {
key.toString(), "string", getContext().getPackageName()));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -702,4 +702,4 @@ private String getPermissionConstantValue(String key) {
return getContext().getString(getContextResources().getIdentifier(
key.toString(), "string", getContext().getPackageName()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,11 @@ public static void displayNotification(Context context, int icon, String title,
mBuilder.setContentIntent(resultPendingIntent);

NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(tag, id, mBuilder.build());
if (mNotificationManager != null) {
mNotificationManager.notify(tag, id, mBuilder.build());
} else {
Log.w(TAG, "Unable to retrieve notification manager.");
}
}

public static Date currentDate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,4 +676,4 @@ private COSUProfilePolicy() {
public static final String OPERATION_VALUE_COMPLETED = "COMPLETED";
public static final String OPERATION_VALUE_ERROR = "ERROR";

}
}
2 changes: 1 addition & 1 deletion client/client/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,4 @@

<!-- Screen sharing-->
<string name="intent_extra_screen_share">screenShare</string>
</resources>
</resources>
18 changes: 18 additions & 0 deletions client/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
org.gradle.daemon=true

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true

# Enables new incubating mode that makes Gradle selective when configuring projects.
# Only relevant projects are configured which results in faster builds for large multi-projects.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true
2 changes: 1 addition & 1 deletion client/iDPProxy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ android {
dependencies {
compile 'commons-codec:commons-codec:20041127.091804'
compile 'com.android.volley:volley:1.0.0'
}
}

0 comments on commit f1bb3ed

Please sign in to comment.