forked from jens/Automation
ringtone
This commit is contained in:
parent
92e405d396
commit
34883519e4
@ -12,6 +12,7 @@ import android.location.Location;
|
|||||||
import android.location.LocationListener;
|
import android.location.LocationListener;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -136,42 +137,45 @@ public class ActivityManagePoi extends Activity
|
|||||||
|
|
||||||
private void getLocation()
|
private void getLocation()
|
||||||
{
|
{
|
||||||
Criteria critNetwork = new Criteria();
|
Criteria criteriaNetwork = new Criteria();
|
||||||
critNetwork.setPowerRequirement(Criteria.POWER_LOW);
|
criteriaNetwork.setPowerRequirement(Criteria.POWER_LOW);
|
||||||
critNetwork.setAltitudeRequired(false);
|
criteriaNetwork.setAltitudeRequired(false);
|
||||||
critNetwork.setSpeedRequired(false);
|
criteriaNetwork.setSpeedRequired(false);
|
||||||
critNetwork.setBearingRequired(false);
|
criteriaNetwork.setBearingRequired(false);
|
||||||
critNetwork.setCostAllowed(false);
|
criteriaNetwork.setCostAllowed(false);
|
||||||
critNetwork.setAccuracy(Criteria.ACCURACY_COARSE);
|
criteriaNetwork.setAccuracy(Criteria.ACCURACY_COARSE);
|
||||||
|
|
||||||
Criteria critGps = new Criteria();
|
Criteria criteriaGps = new Criteria();
|
||||||
critGps.setAltitudeRequired(false);
|
criteriaGps.setAltitudeRequired(false);
|
||||||
critGps.setSpeedRequired(false);
|
criteriaGps.setSpeedRequired(false);
|
||||||
critGps.setBearingRequired(false);
|
criteriaGps.setBearingRequired(false);
|
||||||
critGps.setCostAllowed(true);
|
criteriaGps.setCostAllowed(true);
|
||||||
critGps.setAccuracy(Criteria.ACCURACY_FINE);
|
criteriaGps.setAccuracy(Criteria.ACCURACY_FINE);
|
||||||
|
|
||||||
String provider1 = myLocationManager.getBestProvider(critNetwork, true);
|
String provider1 = myLocationManager.getBestProvider(criteriaNetwork, true);
|
||||||
String provider2 = myLocationManager.getBestProvider(critGps, true);
|
String provider2 = myLocationManager.getBestProvider(criteriaGps, true);
|
||||||
// String provider3 = myLocationManager.getProvider("wifi");
|
// String provider3 = myLocationManager.getProvider("wifi");
|
||||||
|
|
||||||
if(provider1 == null | provider2 == null)
|
if(provider1 == null || provider2 == null)
|
||||||
{
|
{
|
||||||
Toast.makeText(this, getResources().getString(R.string.logNoSuitableProvider), Toast.LENGTH_LONG).show();
|
Toast.makeText(this, getResources().getString(R.string.logNoSuitableProvider), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(provider1.equals(provider2))
|
||||||
|
Miscellaneous.logEvent("i", "POI Manager", "Both location providers are equal. Only one will be used.", 4);
|
||||||
|
|
||||||
locationSearchStart = Calendar.getInstance();
|
locationSearchStart = Calendar.getInstance();
|
||||||
startTimeout();
|
startTimeout();
|
||||||
|
|
||||||
if(!Settings.privacyLocationing || !ConnectivityReceiver.isDataConnectionAvailable(AutomationService.getInstance()))
|
if(!Settings.privacyLocationing && !ConnectivityReceiver.isDataConnectionAvailable(Miscellaneous.getAnyContext()) && !provider1.equals(provider2))
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "POI Manager", getResources().getString(R.string.logGettingPositionWithProvider) + " " + provider1, 3);
|
Miscellaneous.logEvent("i", "POI Manager", getResources().getString(R.string.logGettingPositionWithProvider) + " " + provider1, 3);
|
||||||
myLocationManager.requestLocationUpdates(provider1, 500, Settings.satisfactoryAccuracyNetwork, myLocationListenerNetwork);
|
myLocationManager.requestLocationUpdates(provider1, 500, Settings.satisfactoryAccuracyNetwork, myLocationListenerNetwork);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Miscellaneous.logEvent("i", "POI Manager", "Skipping network location query because private locationing is active.", 4);
|
Miscellaneous.logEvent("i", "POI Manager", "Skipping network location.", 4);
|
||||||
|
|
||||||
Miscellaneous.logEvent("i", "POI Manager", getResources().getString(R.string.logGettingPositionWithProvider) + " " + provider2, 3);
|
Miscellaneous.logEvent("i", "POI Manager", getResources().getString(R.string.logGettingPositionWithProvider) + " " + provider2, 3);
|
||||||
myLocationManager.requestLocationUpdates(provider2, 500, Settings.satisfactoryAccuracyGps, myLocationListenerGps);
|
myLocationManager.requestLocationUpdates(provider2, 500, Settings.satisfactoryAccuracyGps, myLocationListenerGps);
|
||||||
@ -310,6 +314,20 @@ public class ActivityManagePoi extends Activity
|
|||||||
public void onClick(DialogInterface dialog, int which)
|
public void onClick(DialogInterface dialog, int which)
|
||||||
{
|
{
|
||||||
progressDialog = ProgressDialog.show(ActivityManagePoi.this, "", getResources().getString(R.string.gettingPosition), true, true);
|
progressDialog = ProgressDialog.show(ActivityManagePoi.this, "", getResources().getString(R.string.gettingPosition), true, true);
|
||||||
|
if(Build.VERSION.SDK_INT >= 31)
|
||||||
|
{
|
||||||
|
AlertDialog dia = Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.locationNotWorkingOn12), ActivityManagePoi.this);
|
||||||
|
dia.setOnDismissListener(new DialogInterface.OnDismissListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialogInterface)
|
||||||
|
{
|
||||||
|
getLocation();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dia.show();
|
||||||
|
}
|
||||||
|
else
|
||||||
getLocation();
|
getLocation();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -520,6 +520,9 @@ public class ActivityPermissions extends Activity
|
|||||||
addToArrayListUnique(Manifest.permission.MODIFY_AUDIO_SETTINGS, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.MODIFY_AUDIO_SETTINGS, requiredPermissions);
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||||
addToArrayListUnique(Manifest.permission.ACCESS_NOTIFICATION_POLICY, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.ACCESS_NOTIFICATION_POLICY, requiredPermissions);
|
||||||
|
Profile targetProfile = Profile.getByName(action.getParameter2());
|
||||||
|
if(targetProfile.changeIncomingCallsRingtone || targetProfile.changeNotificationRingtone)
|
||||||
|
addToArrayListUnique(Manifest.permission.READ_EXTERNAL_STORAGE, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case disableScreenRotation:
|
case disableScreenRotation:
|
||||||
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
|
||||||
@ -861,6 +864,8 @@ public class ActivityPermissions extends Activity
|
|||||||
case Manifest.permission.READ_EXTERNAL_STORAGE:
|
case Manifest.permission.READ_EXTERNAL_STORAGE:
|
||||||
for(String ruleName : getRulesUsing(Action.Action_Enum.playSound))
|
for(String ruleName : getRulesUsing(Action.Action_Enum.playSound))
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
|
for(String ruleName : getRulesUsing(Action.Action_Enum.changeSoundProfile))
|
||||||
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
break;
|
break;
|
||||||
case Manifest.permission.BIND_DEVICE_ADMIN:
|
case Manifest.permission.BIND_DEVICE_ADMIN:
|
||||||
for(String ruleName : getRulesUsing(Action.Action_Enum.turnScreenOnOrOff))
|
for(String ruleName : getRulesUsing(Action.Action_Enum.turnScreenOnOrOff))
|
||||||
|
@ -327,6 +327,12 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
ReceiverCoordinator.startAllReceivers();
|
ReceiverCoordinator.startAllReceivers();
|
||||||
|
|
||||||
PackageReplacedReceiver.setHasServiceBeenRunning(true, this);
|
PackageReplacedReceiver.setHasServiceBeenRunning(true, this);
|
||||||
|
|
||||||
|
for(Rule r : Rule.getRuleCollection())
|
||||||
|
{
|
||||||
|
if(r.getsGreenLight(AutomationService.this))
|
||||||
|
r.activate(AutomationService.this, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void startLocationProvider()
|
protected void startLocationProvider()
|
||||||
|
@ -8,6 +8,7 @@ import android.app.NotificationChannel;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
|
import android.content.ContentUris;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -24,6 +25,7 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.provider.DocumentsContract;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.provider.Settings.Secure;
|
import android.provider.Settings.Secure;
|
||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
@ -73,8 +75,10 @@ import java.math.BigDecimal;
|
|||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.security.DigestInputStream;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
@ -1189,7 +1193,8 @@ public class Miscellaneous extends Service
|
|||||||
|
|
||||||
public static double round(double value, int places)
|
public static double round(double value, int places)
|
||||||
{
|
{
|
||||||
if (places < 0) throw new IllegalArgumentException();
|
if (places < 0)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
BigDecimal bd = new BigDecimal(Double.toString(value));
|
BigDecimal bd = new BigDecimal(Double.toString(value));
|
||||||
bd = bd.setScale(places, RoundingMode.HALF_UP);
|
bd = bd.setScale(places, RoundingMode.HALF_UP);
|
||||||
@ -1201,7 +1206,7 @@ public class Miscellaneous extends Service
|
|||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String[] proj = { MediaStore.Images.Media.DATA };
|
String[] proj = { MediaStore.Images.Media.DATA, MediaStore.Audio.Media.DATA };
|
||||||
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
|
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
|
||||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
@ -1221,6 +1226,114 @@ public class Miscellaneous extends Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getRealPathFromURI2(final Context context, final Uri uri)
|
||||||
|
{
|
||||||
|
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||||
|
|
||||||
|
// DocumentProvider
|
||||||
|
if (isKitKat && DocumentsContract.isDocumentUri(context, uri))
|
||||||
|
{
|
||||||
|
// ExternalStorageProvider
|
||||||
|
if (isExternalStorageDocument(uri))
|
||||||
|
{
|
||||||
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
|
final String[] split = docId.split(":");
|
||||||
|
final String type = split[0];
|
||||||
|
|
||||||
|
if ("primary".equalsIgnoreCase(type))
|
||||||
|
{
|
||||||
|
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// DownloadsProvider
|
||||||
|
else if (isDownloadsDocument(uri))
|
||||||
|
{
|
||||||
|
|
||||||
|
final String id = DocumentsContract.getDocumentId(uri);
|
||||||
|
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
||||||
|
|
||||||
|
return getDataColumn(context, contentUri, null, null);
|
||||||
|
}
|
||||||
|
// MediaProvider
|
||||||
|
else if (isMediaDocument(uri))
|
||||||
|
{
|
||||||
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
|
final String[] split = docId.split(":");
|
||||||
|
final String type = split[0];
|
||||||
|
|
||||||
|
Uri contentUri = null;
|
||||||
|
if ("image".equals(type))
|
||||||
|
{
|
||||||
|
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
}
|
||||||
|
else if ("video".equals(type))
|
||||||
|
{
|
||||||
|
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
}
|
||||||
|
else if ("audio".equals(type))
|
||||||
|
{
|
||||||
|
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String selection = "_id=?";
|
||||||
|
final String[] selectionArgs = new String[] { split[1] };
|
||||||
|
|
||||||
|
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// MediaStore (and general)
|
||||||
|
else if ("content".equalsIgnoreCase(uri.getScheme()))
|
||||||
|
{
|
||||||
|
return getDataColumn(context, uri, null, null);
|
||||||
|
}
|
||||||
|
// File
|
||||||
|
else if ("file".equalsIgnoreCase(uri.getScheme()))
|
||||||
|
{
|
||||||
|
return uri.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs)
|
||||||
|
{
|
||||||
|
Cursor cursor = null;
|
||||||
|
final String column = "_data";
|
||||||
|
final String[] projection = { column };
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
|
||||||
|
null);
|
||||||
|
if (cursor != null && cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
final int column_index = cursor.getColumnIndexOrThrow(column);
|
||||||
|
return cursor.getString(column_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (cursor != null)
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isExternalStorageDocument(Uri uri)
|
||||||
|
{
|
||||||
|
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDownloadsDocument(Uri uri)
|
||||||
|
{
|
||||||
|
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isMediaDocument(Uri uri)
|
||||||
|
{
|
||||||
|
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||||
|
}
|
||||||
|
|
||||||
public static Method getClassMethodReflective(String className, String methodName)
|
public static Method getClassMethodReflective(String className, String methodName)
|
||||||
{
|
{
|
||||||
Class foundClass = null;
|
Class foundClass = null;
|
||||||
@ -1754,4 +1867,35 @@ public class Miscellaneous extends Service
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String checksumSha(String filepath) throws IOException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MessageDigest md = null;
|
||||||
|
md = MessageDigest.getInstance("SHA-256");
|
||||||
|
|
||||||
|
// file hashing with DigestInputStream
|
||||||
|
try (DigestInputStream dis = new DigestInputStream(new FileInputStream(filepath), md))
|
||||||
|
{
|
||||||
|
while (dis.read() != -1)
|
||||||
|
; //empty loop to clear the data
|
||||||
|
md = dis.getMessageDigest();
|
||||||
|
}
|
||||||
|
|
||||||
|
// bytes to hex
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (byte b : md.digest())
|
||||||
|
{
|
||||||
|
result.append(String.format("%02x", b));
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
catch (NoSuchAlgorithmException e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "shaChecksum", Log.getStackTraceString(e), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,10 +4,12 @@ import android.app.NotificationManager;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
|
import android.media.Ringtone;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -636,13 +638,33 @@ public class Profile implements Comparable<Profile>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(changeIncomingCallsRingtone)
|
/*if (changeIncomingCallsRingtone)
|
||||||
// {
|
{
|
||||||
// if (incomingCallsRingtone != null)
|
if (incomingCallsRingtone != null)
|
||||||
// {
|
{
|
||||||
// applyRingTone(incomingCallsRingtone, RingtoneManager.TYPE_RINGTONE, context);
|
Uri ringtone_uri = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE);
|
||||||
// }
|
|
||||||
// }
|
if (ringtone_uri != null)
|
||||||
|
{
|
||||||
|
// if ringtone_uri is null get Default Ringtone
|
||||||
|
ringtone_uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
|
||||||
|
|
||||||
|
Ringtone currentRingtone = RingtoneManager.getRingtone(context, ringtone_uri);
|
||||||
|
String title = currentRingtone.getTitle(context);
|
||||||
|
*//* Ringtone desiredRingtone = RingtoneManager.getRingtone(context, Uri.fromFile(notificationRingtone));
|
||||||
|
boolean result = currentRingtone.equals(desiredRingtone);*//*
|
||||||
|
|
||||||
|
Uri desired_ringtone = MediaStore.Audio.Media.getContentUriForPath(incomingCallsRingtone.getAbsolutePath());
|
||||||
|
|
||||||
|
// File currentRingtoneFile = new File(Miscellaneous.getRealPathFromURI(context, ringtone_uri));
|
||||||
|
String currentChecksum = Miscellaneous.checksumSha(ringtone_uri.getPath());
|
||||||
|
String desiredChecksum = Miscellaneous.checksumSha(incomingCallsRingtone.getAbsolutePath());
|
||||||
|
|
||||||
|
if (!currentChecksum.equals(desiredChecksum))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
if (changeVibrateWhenRinging)
|
if (changeVibrateWhenRinging)
|
||||||
{
|
{
|
||||||
@ -660,9 +682,31 @@ public class Profile implements Comparable<Profile>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(changeNotificationRingtone)
|
/*if (changeNotificationRingtone)
|
||||||
// if(notificationRingtone != null)
|
{
|
||||||
// applyRingTone(notificationRingtone, RingtoneManager.TYPE_NOTIFICATION, context);
|
if (notificationRingtone != null)
|
||||||
|
{
|
||||||
|
Uri ringtone_uri = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_NOTIFICATION);
|
||||||
|
|
||||||
|
if (ringtone_uri == null)
|
||||||
|
{
|
||||||
|
// if ringtone_uri is null get Default Ringtone
|
||||||
|
ringtone_uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
|
||||||
|
|
||||||
|
File currentRingtone = new File(Settings.System.DEFAULT_NOTIFICATION_URI.getPath());
|
||||||
|
|
||||||
|
// File currentRingtone = new File(Miscellaneous.getRealPathFromURI(context, ringtone_uri));
|
||||||
|
|
||||||
|
String currentChecksum = Miscellaneous.checksumSha(currentRingtone.getAbsolutePath());
|
||||||
|
String desiredChecksum = Miscellaneous.checksumSha(notificationRingtone.getAbsolutePath());
|
||||||
|
|
||||||
|
if(!currentChecksum.equals(desiredChecksum))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
if(changeScreenLockUnlockSound)
|
if(changeScreenLockUnlockSound)
|
||||||
{
|
{
|
||||||
|
@ -81,54 +81,54 @@ public class Settings implements SharedPreferences
|
|||||||
*/
|
*/
|
||||||
public static final String dateFormat = "E dd.MM.yyyy HH:mm:ss:ssss";
|
public static final String dateFormat = "E dd.MM.yyyy HH:mm:ss:ssss";
|
||||||
|
|
||||||
protected static final int default_positioningEngine = 0;
|
public static final int default_positioningEngine = 0;
|
||||||
protected static final long default_minimumDistanceChangeForGpsUpdate = 100;
|
public static final long default_minimumDistanceChangeForGpsUpdate = 100;
|
||||||
protected static final long default_minimumDistanceChangeForNetworkUpdate = 500; // in Meters
|
public static final long default_minimumDistanceChangeForNetworkUpdate = 500; // in Meters
|
||||||
protected static final long default_satisfactoryAccuracyGps = 50;
|
public static final long default_satisfactoryAccuracyGps = 50;
|
||||||
protected static final long default_satisfactoryAccuracyNetwork = 1000;
|
public static final long default_satisfactoryAccuracyNetwork = 1000;
|
||||||
protected static final int default_gpsTimeout = 300; // seconds
|
public static final int default_gpsTimeout = 300; // seconds
|
||||||
protected static final long default_minimumTimeBetweenUpdate = 30000; // in Milliseconds
|
public static final long default_minimumTimeBetweenUpdate = 30000; // in Milliseconds
|
||||||
protected static final boolean default_startServiceAtSystemBoot = false;
|
public static final boolean default_startServiceAtSystemBoot = false;
|
||||||
protected static final boolean default_writeLogFile = false;
|
public static final boolean default_writeLogFile = false;
|
||||||
protected static final long default_logLevel = 2;
|
public static final long default_logLevel = 2;
|
||||||
protected static final int default_logFileMaxSize = 10;
|
public static final int default_logFileMaxSize = 10;
|
||||||
protected static final boolean default_useTextToSpeechOnNormal = false;
|
public static final boolean default_useTextToSpeechOnNormal = false;
|
||||||
protected static final boolean default_useTextToSpeechOnVibrate = false;
|
public static final boolean default_useTextToSpeechOnVibrate = false;
|
||||||
protected static final boolean default_useTextToSpeechOnSilent = false;
|
public static final boolean default_useTextToSpeechOnSilent = false;
|
||||||
protected static final boolean default_muteTextToSpeechDuringCalls = true;
|
public static final boolean default_muteTextToSpeechDuringCalls = true;
|
||||||
protected static final boolean default_useWifiForPositioning = true;
|
public static final boolean default_useWifiForPositioning = true;
|
||||||
protected static final boolean default_useAccelerometerForPositioning = true;
|
public static final boolean default_useAccelerometerForPositioning = true;
|
||||||
protected static final long default_useAccelerometerAfterIdleTime = 5;
|
public static final long default_useAccelerometerAfterIdleTime = 5;
|
||||||
protected static final long default_accelerometerMovementThreshold = 2;
|
public static final long default_accelerometerMovementThreshold = 2;
|
||||||
protected static final long default_speedMaximumTimeBetweenLocations = 4;
|
public static final long default_speedMaximumTimeBetweenLocations = 4;
|
||||||
protected static final long default_timeBetweenNoiseLevelMeasurements = 60;
|
public static final long default_timeBetweenNoiseLevelMeasurements = 60;
|
||||||
protected static final long default_lengthOfNoiseLevelMeasurements = 5;
|
public static final long default_lengthOfNoiseLevelMeasurements = 5;
|
||||||
protected static final long default_referenceValueForNoiseLevelMeasurements = 20;
|
public static final long default_referenceValueForNoiseLevelMeasurements = 20;
|
||||||
protected static final boolean default_hasServiceBeenRunning = false;
|
public static final boolean default_hasServiceBeenRunning = false;
|
||||||
protected static final boolean default_startServiceAfterAppUpdate = true;
|
public static final boolean default_startServiceAfterAppUpdate = true;
|
||||||
protected static final boolean default_startNewThreadForRuleActivation = true;
|
public static final boolean default_startNewThreadForRuleActivation = true;
|
||||||
protected static final boolean default_showIconWhenServiceIsRunning = true;
|
public static final boolean default_showIconWhenServiceIsRunning = true;
|
||||||
protected static final boolean default_httpAcceptAllCertificates = false;
|
public static final boolean default_httpAcceptAllCertificates = false;
|
||||||
protected static final int default_httpAttempts = 3;
|
public static final int default_httpAttempts = 3;
|
||||||
protected static final int default_httpAttemptsTimeout = 60;
|
public static final int default_httpAttemptsTimeout = 60;
|
||||||
protected static final int default_httpAttemptGap = 2;
|
public static final int default_httpAttemptGap = 2;
|
||||||
protected static final PointOfInterest default_lastActivePoi = null;
|
public static final PointOfInterest default_lastActivePoi = null;
|
||||||
protected static final boolean default_rememberLastActivePoi = true;
|
public static final boolean default_rememberLastActivePoi = true;
|
||||||
protected static final int default_locationRingBufferSize=3;
|
public static final int default_locationRingBufferSize=3;
|
||||||
protected static final long default_timeBetweenProcessMonitorings = 60;
|
public static final long default_timeBetweenProcessMonitorings = 60;
|
||||||
protected static final long default_acceptDevicePositionSignalEveryX_MilliSeconds = 1000;
|
public static final long default_acceptDevicePositionSignalEveryX_MilliSeconds = 1000;
|
||||||
protected static final int default_activityDetectionFrequency = 60;
|
public static final int default_activityDetectionFrequency = 60;
|
||||||
protected static final int default_activityDetectionRequiredProbability = 75;
|
public static final int default_activityDetectionRequiredProbability = 75;
|
||||||
protected static final boolean default_privacyLocationing = false;
|
public static final boolean default_privacyLocationing = false;
|
||||||
protected static final int default_startScreen = 0;
|
public static final int default_startScreen = 0;
|
||||||
protected static final int default_tabsPlacement = 0;
|
public static final int default_tabsPlacement = 0;
|
||||||
protected static final boolean default_executeRulesAndProfilesWithSingleClick = false;
|
public static final boolean default_executeRulesAndProfilesWithSingleClick = false;
|
||||||
protected static final boolean default_displayNewsOnMainScreen = false;
|
public static final boolean default_displayNewsOnMainScreen = false;
|
||||||
protected static final boolean default_automaticUpdateCheck = false;
|
public static final boolean default_automaticUpdateCheck = false;
|
||||||
protected static final boolean default_lockSoundChanges = false;
|
public static final boolean default_lockSoundChanges = false;
|
||||||
protected static final long default_lastNewsPolltime = -1;
|
public static final long default_lastNewsPolltime = -1;
|
||||||
protected static final long default_lastUpdateCheck = -1;
|
public static final long default_lastUpdateCheck = -1;
|
||||||
protected static final long default_musicCheckFrequency = 2500;
|
public static final long default_musicCheckFrequency = 2500;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(String arg0)
|
public boolean contains(String arg0)
|
||||||
@ -265,6 +265,9 @@ public class Settings implements SharedPreferences
|
|||||||
|
|
||||||
musicCheckFrequency = Long.parseLong(prefs.getString("musicCheckFrequency", String.valueOf(default_musicCheckFrequency)));
|
musicCheckFrequency = Long.parseLong(prefs.getString("musicCheckFrequency", String.valueOf(default_musicCheckFrequency)));
|
||||||
|
|
||||||
|
if(Settings.musicCheckFrequency == 0)
|
||||||
|
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
|
||||||
|
|
||||||
executeRulesAndProfilesWithSingleClick = prefs.getBoolean("executeRulesAndProfilesWithSingleClick", default_executeRulesAndProfilesWithSingleClick);
|
executeRulesAndProfilesWithSingleClick = prefs.getBoolean("executeRulesAndProfilesWithSingleClick", default_executeRulesAndProfilesWithSingleClick);
|
||||||
automaticUpdateCheck = prefs.getBoolean("automaticUpdateCheck", default_automaticUpdateCheck);
|
automaticUpdateCheck = prefs.getBoolean("automaticUpdateCheck", default_automaticUpdateCheck);
|
||||||
displayNewsOnMainScreen = prefs.getBoolean("displayNewsOnMainScreen", default_displayNewsOnMainScreen);
|
displayNewsOnMainScreen = prefs.getBoolean("displayNewsOnMainScreen", default_displayNewsOnMainScreen);
|
||||||
@ -546,6 +549,9 @@ public class Settings implements SharedPreferences
|
|||||||
editor.putBoolean("executeRulesAndProfilesWithSingleClick", executeRulesAndProfilesWithSingleClick);
|
editor.putBoolean("executeRulesAndProfilesWithSingleClick", executeRulesAndProfilesWithSingleClick);
|
||||||
editor.putBoolean("automaticUpdateCheck", automaticUpdateCheck);
|
editor.putBoolean("automaticUpdateCheck", automaticUpdateCheck);
|
||||||
editor.putBoolean("displayNewsOnMainScreen", displayNewsOnMainScreen);
|
editor.putBoolean("displayNewsOnMainScreen", displayNewsOnMainScreen);
|
||||||
|
|
||||||
|
if(Settings.musicCheckFrequency == 0)
|
||||||
|
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
|
||||||
editor.putString("musicCheckFrequency", String.valueOf(musicCheckFrequency));
|
editor.putString("musicCheckFrequency", String.valueOf(musicCheckFrequency));
|
||||||
|
|
||||||
editor.putBoolean("lockSoundChanges", lockSoundChanges);
|
editor.putBoolean("lockSoundChanges", lockSoundChanges);
|
||||||
|
@ -232,12 +232,6 @@ public class LocationProvider
|
|||||||
|
|
||||||
public void startLocationService()
|
public void startLocationService()
|
||||||
{
|
{
|
||||||
// if(Settings.useAccelerometerForPositioning && !Miscellaneous.isAndroidEmulator())
|
|
||||||
// {
|
|
||||||
// accelerometerHandler = new AccelerometerHandler();
|
|
||||||
// mySensorActivity = new SensorActivity(this);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// startPhoneStateListener
|
// startPhoneStateListener
|
||||||
PhoneStatusListener.startPhoneStatusListener(parentService); // also used to mute anouncements during calls
|
PhoneStatusListener.startPhoneStatusListener(parentService); // also used to mute anouncements during calls
|
||||||
|
|
||||||
@ -248,8 +242,6 @@ public class LocationProvider
|
|||||||
{
|
{
|
||||||
if(Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) | Rule.isAnyRuleUsing(Trigger_Enum.speed))
|
if(Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) | Rule.isAnyRuleUsing(Trigger_Enum.speed))
|
||||||
{
|
{
|
||||||
// TelephonyManager telephonyManager = (TelephonyManager) AutomationService.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
|
|
||||||
// startCellLocationChangedReceiver
|
// startCellLocationChangedReceiver
|
||||||
if (CellLocationChangedReceiver.isCellLocationChangedReceiverPossible())
|
if (CellLocationChangedReceiver.isCellLocationChangedReceiverPossible())
|
||||||
{
|
{
|
||||||
@ -514,7 +506,6 @@ public class LocationProvider
|
|||||||
Message msg = new Message();
|
Message msg = new Message();
|
||||||
msg.what = 1;
|
msg.what = 1;
|
||||||
speedHandler.sendMessageAtTime(msg, timeOfForcedLocationCheck.getTimeInMillis());
|
speedHandler.sendMessageAtTime(msg, timeOfForcedLocationCheck.getTimeInMillis());
|
||||||
// speedHandler.sendMessageDelayed(msg, delayTime);
|
|
||||||
speedTimerActive = true;
|
speedTimerActive = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -531,7 +522,7 @@ public class LocationProvider
|
|||||||
if(msg.what == 1)
|
if(msg.what == 1)
|
||||||
{
|
{
|
||||||
// time is up, no cell location updates since x minutes, start accelerometer
|
// time is up, no cell location updates since x minutes, start accelerometer
|
||||||
String text = "Timer triggered. Based on the last location and speed we may be at a POI. Forcing location update in case CellLocationChangedReceiver didn\'t fire.";
|
Miscellaneous.logEvent("i", "LocationProvider", "Timer triggered. Based on the last location and speed we may be at a POI. Forcing location update in case CellLocationChangedReceiver didn\'t fire.", 5);
|
||||||
|
|
||||||
Location currentLocation = CellLocationChangedReceiver.getInstance().getLocation("coarse");
|
Location currentLocation = CellLocationChangedReceiver.getInstance().getLocation("coarse");
|
||||||
AutomationService.getInstance().getLocationProvider().setCurrentLocation(currentLocation, false);
|
AutomationService.getInstance().getLocationProvider().setCurrentLocation(currentLocation, false);
|
||||||
|
@ -10,6 +10,7 @@ import com.jens.automation2.Settings;
|
|||||||
import com.jens.automation2.Trigger;
|
import com.jens.automation2.Trigger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
@ -793,4 +793,5 @@
|
|||||||
<string name="musicPlayingDetection">Music playing detection</string>
|
<string name="musicPlayingDetection">Music playing detection</string>
|
||||||
<string name="musicCheckFrequencyTitle">Check frequency [ms]</string>
|
<string name="musicCheckFrequencyTitle">Check frequency [ms]</string>
|
||||||
<string name="musicCheckFrequencySummary">Milliseconds between checks</string>
|
<string name="musicCheckFrequencySummary">Milliseconds between checks</string>
|
||||||
|
<string name="locationNotWorkingOn12">Getting the location does not seem to be working on Android 12 devices currently. If it isn\'t working for you, I\'m sorry. I\'ll try to fix this as soon as I know the cause. So if the donut doesn\'t stop spinning, you know why.</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user