Changed settings location to regular data folder. Migration of files in existing installations pending.
This commit is contained in:
parent
f9cf3356e7
commit
d803d57af1
@ -53,11 +53,11 @@ public class ActivityMainPoi extends ActivityGeneric
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainPoi.this))
|
// if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainPoi.this))
|
||||||
{
|
// {
|
||||||
Toast.makeText(ActivityMainPoi.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
// Toast.makeText(ActivityMainPoi.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(!ActivityPermissions.havePermission(ActivityPermissions.permissionNameLocationCoarse, ActivityMainPoi.this) || !ActivityPermissions.havePermission(ActivityPermissions.permissionNameLocationFine, ActivityMainPoi.this))
|
if(!ActivityPermissions.havePermission(ActivityPermissions.permissionNameLocationCoarse, ActivityMainPoi.this) || !ActivityPermissions.havePermission(ActivityPermissions.permissionNameLocationFine, ActivityMainPoi.this))
|
||||||
{
|
{
|
||||||
|
@ -50,11 +50,11 @@ public class ActivityMainProfiles extends ActivityGeneric
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainProfiles.this))
|
// if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainProfiles.this))
|
||||||
{
|
// {
|
||||||
Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
// Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
profileToEdit = null;
|
profileToEdit = null;
|
||||||
Intent manageSpecificProfileIntent = new Intent (ActivityMainProfiles.this, ActivityManageProfile.class);
|
Intent manageSpecificProfileIntent = new Intent (ActivityMainProfiles.this, ActivityManageProfile.class);
|
||||||
|
@ -52,11 +52,11 @@ public class ActivityMainRules extends ActivityGeneric
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainRules.this))
|
// if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainRules.this))
|
||||||
{
|
// {
|
||||||
Toast.makeText(ActivityMainRules.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
// Toast.makeText(ActivityMainRules.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
ruleToEdit = null;
|
ruleToEdit = null;
|
||||||
Intent startAddRuleIntent = new Intent(ActivityMainRules.this, ActivityManageRule.class);
|
Intent startAddRuleIntent = new Intent(ActivityMainRules.this, ActivityManageRule.class);
|
||||||
|
@ -281,8 +281,8 @@ public class ActivityPermissions extends Activity
|
|||||||
addToArrayListUnique("android.permission.RECEIVE_BOOT_COMPLETED", requiredPermissions);
|
addToArrayListUnique("android.permission.RECEIVE_BOOT_COMPLETED", requiredPermissions);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!havePermission("android.permission.WRITE_EXTERNAL_STORAGE", workingContext))
|
// if (!havePermission(ActivityPermissions.writeExternalStoragePermissionName, workingContext))
|
||||||
addToArrayListUnique("android.permission.WRITE_EXTERNAL_STORAGE", requiredPermissions);
|
// addToArrayListUnique(ActivityPermissions.writeExternalStoragePermissionName, requiredPermissions);
|
||||||
|
|
||||||
for(Profile profile : Profile.getProfileCollection())
|
for(Profile profile : Profile.getProfileCollection())
|
||||||
{
|
{
|
||||||
|
@ -106,17 +106,17 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
|
|
||||||
public boolean checkStartupRequirements(Context context, boolean startAtBoot)
|
public boolean checkStartupRequirements(Context context, boolean startAtBoot)
|
||||||
{
|
{
|
||||||
if (!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, AutomationService.this))
|
// if (!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, AutomationService.this))
|
||||||
{
|
// {
|
||||||
/*
|
// /*
|
||||||
Don't have permission to access external storage. This is a show stopper as
|
// Don't have permission to access external storage. This is a show stopper as
|
||||||
the configuration file is stored on external storage.
|
// the configuration file is stored on external storage.
|
||||||
*/
|
// */
|
||||||
Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
|
// Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
|
||||||
// Toast.makeText(AutomationService.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
//// Toast.makeText(AutomationService.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
||||||
ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
|
// ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= 28)
|
if(Build.VERSION.SDK_INT >= 28)
|
||||||
{
|
{
|
||||||
|
@ -313,42 +313,52 @@ public class Miscellaneous extends Service
|
|||||||
{
|
{
|
||||||
if(writeableFolderStringCache == null)
|
if(writeableFolderStringCache == null)
|
||||||
{
|
{
|
||||||
String testPath = null;
|
if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, Miscellaneous.getAnyContext()))
|
||||||
File folder = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
String[] foldersToTestArray = new String[]
|
// Use the app-specific folder as new default.
|
||||||
{
|
|
||||||
Environment.getExternalStorageDirectory().getAbsolutePath(),
|
|
||||||
"/storage/emulated/0",
|
|
||||||
"/HWUserData",
|
|
||||||
"/mnt/sdcard"
|
|
||||||
};
|
|
||||||
|
|
||||||
for(String f : foldersToTestArray)
|
writeableFolderStringCache = Miscellaneous.getAnyContext().getFilesDir().getAbsolutePath();
|
||||||
|
return writeableFolderStringCache;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//TODO: We have the storage permission, probably because it's an old installation. Files should be migrated to app-specific folder.
|
||||||
|
String testPath = null;
|
||||||
|
File folder = null;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (testFolder(f))
|
String[] foldersToTestArray = new String[]
|
||||||
|
{
|
||||||
|
Environment.getExternalStorageDirectory().getAbsolutePath(),
|
||||||
|
"/storage/emulated/0",
|
||||||
|
"/HWUserData",
|
||||||
|
"/mnt/sdcard"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (String f : foldersToTestArray)
|
||||||
{
|
{
|
||||||
String pathToUse = f + "/" + Settings.folderName;
|
if (testFolder(f))
|
||||||
Miscellaneous.logEvent("i", "Path", "Using " + pathToUse + " to store settings and log.", 2);
|
{
|
||||||
|
String pathToUse = f + "/" + Settings.folderName;
|
||||||
|
Miscellaneous.logEvent("i", "Path", "Using " + pathToUse + " to store settings and log.", 2);
|
||||||
// Toast.makeText(getAnyContext(), "Using " + pathToUse + " to store settings and log.", Toast.LENGTH_LONG).show();
|
// Toast.makeText(getAnyContext(), "Using " + pathToUse + " to store settings and log.", Toast.LENGTH_LONG).show();
|
||||||
return pathToUse;
|
return pathToUse;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Miscellaneous.logEvent("e", "getWritableFolder", folder.getAbsolutePath() + " does not exist and could not be created.", 3);
|
||||||
}
|
}
|
||||||
else
|
} catch (Exception e)
|
||||||
Miscellaneous.logEvent("e", "getWritableFolder", folder.getAbsolutePath() + " does not exist and could not be created.", 3);
|
{
|
||||||
|
Log.w("getWritableFolder", folder + " not writable.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
Log.w("getWritableFolder", folder + " not writable.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// do not change to logEvent() - we can't write
|
// do not change to logEvent() - we can't write
|
||||||
Toast.makeText(getAnyContext(), "No writable folder could be found.", Toast.LENGTH_LONG).show();
|
Toast.makeText(getAnyContext(), "No writable folder could be found.", Toast.LENGTH_LONG).show();
|
||||||
Log.e("getWritableFolder", "No writable folder could be found.");
|
Log.e("getWritableFolder", "No writable folder could be found.");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return writeableFolderStringCache;
|
return writeableFolderStringCache;
|
||||||
|
@ -107,7 +107,7 @@ public class Settings implements SharedPreferences
|
|||||||
protected static final boolean default_privacyLocationing = false;
|
protected static final boolean default_privacyLocationing = false;
|
||||||
protected static final int default_startScreen = 0;
|
protected static final int default_startScreen = 0;
|
||||||
protected static final boolean default_executeRulesAndProfilesWithSingleClick = false;
|
protected static final boolean default_executeRulesAndProfilesWithSingleClick = false;
|
||||||
protected static final boolean default_displayNewsOnMainScreen = true;
|
protected static final boolean default_displayNewsOnMainScreen = false;
|
||||||
protected static final boolean default_lockSoundChanges = false;
|
protected static final boolean default_lockSoundChanges = false;
|
||||||
protected static final long default_lastNewsPolltime = -1;
|
protected static final long default_lastNewsPolltime = -1;
|
||||||
|
|
||||||
|
@ -344,17 +344,22 @@ public class XmlFileInterface
|
|||||||
|
|
||||||
public static void readFile() throws FileNotFoundException
|
public static void readFile() throws FileNotFoundException
|
||||||
{
|
{
|
||||||
if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, Miscellaneous.getAnyContext()))
|
/*
|
||||||
{
|
Storage location has been moved to app-specific folder in Android/data
|
||||||
/*
|
Hence this permission is not requested any more. If it is already granted we assume the files are on /sdcard or similar.
|
||||||
Don't have permission to access external storage. This is a show stopper as
|
Migration to app-specific folder has yet to be implemented.
|
||||||
the configuration file is stored on external storage.
|
*/
|
||||||
*/
|
// if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, Miscellaneous.getAnyContext()))
|
||||||
Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
|
// {
|
||||||
Toast.makeText(Miscellaneous.getAnyContext(), Miscellaneous.getAnyContext().getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
// /*
|
||||||
ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
|
// Don't have permission to access external storage. This is a show stopper as
|
||||||
return;
|
// the configuration file is stored on external storage.
|
||||||
}
|
// */
|
||||||
|
// Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
|
||||||
|
// Toast.makeText(Miscellaneous.getAnyContext(), Miscellaneous.getAnyContext().getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
||||||
|
// ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If we are here it may be that we just got permission to read storage. We need to check for the
|
If we are here it may be that we just got permission to read storage. We need to check for the
|
||||||
|
Loading…
Reference in New Issue
Block a user