Browse Source

Android: Added external storage read/write permissions to RuntimePermissions class

tags/2021-05-28
hogliux 8 years ago
parent
commit
2cdf30dd46
4 changed files with 30 additions and 3 deletions
  1. +16
    -1
      extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h
  2. +2
    -0
      extras/Projucer/Source/Utility/jucer_PresetIDs.h
  3. +6
    -0
      modules/juce_core/misc/juce_RuntimePermissions.h
  4. +6
    -2
      modules/juce_core/native/java/JuceAppActivity.java

+ 16
- 1
extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h View File

@@ -92,7 +92,8 @@ public:
androidVersionCode, androidMinimumSDK, androidTheme,
androidSharedLibraries, androidStaticLibraries, androidExtraAssetsFolder;
CachedValue<bool> androidInternetNeeded, androidMicNeeded, androidBluetoothNeeded;
CachedValue<bool> androidInternetNeeded, androidMicNeeded, androidBluetoothNeeded,
androidExternalReadPermission, androidExternalWritePermission;
CachedValue<String> androidOtherPermissions;
CachedValue<String> androidKeyStore, androidKeyStorePass, androidKeyAlias, androidKeyAliasPass;
@@ -114,6 +115,8 @@ public:
androidInternetNeeded (settings, Ids::androidInternetNeeded, nullptr, true),
androidMicNeeded (settings, Ids::microphonePermissionNeeded, nullptr, false),
androidBluetoothNeeded (settings, Ids::androidBluetoothNeeded, nullptr, true),
androidExternalReadPermission (settings, Ids::androidExternalReadNeeded, nullptr, true),
androidExternalWritePermission (settings, Ids::androidExternalWriteNeeded, nullptr, true),
androidOtherPermissions (settings, Ids::androidOtherPermissions, nullptr),
androidKeyStore (settings, Ids::androidKeyStore, nullptr, "${user.home}/.android/debug.keystore"),
androidKeyStorePass (settings, Ids::androidKeyStorePass, nullptr, "android"),
@@ -741,6 +744,12 @@ private:
props.add (new BooleanPropertyComponent (androidBluetoothNeeded.getPropertyAsValue(), "Bluetooth permissions Required", "Specify bluetooth permission (required for Bluetooth MIDI)"),
"If enabled, this will set the android.permission.BLUETOOTH and android.permission.BLUETOOTH_ADMIN flag in the manifest. This is required for Bluetooth MIDI on Android.");
props.add (new BooleanPropertyComponent (androidExternalReadPermission.getPropertyAsValue(), "Read from external storage", "Specify permissions to read from external storage"),
"If enabled, this will set the android.permission.READ_EXTERNAL_STORAGE flag in the manifest.");
props.add (new BooleanPropertyComponent (androidExternalWritePermission.getPropertyAsValue(), "Write to external storage", "Specify permissions to write to external storage"),
"If enabled, this will set the android.permission.WRITE_EXTERNAL_STORAGE flag in the manifest.");
props.add (new TextPropertyComponent (androidOtherPermissions.getPropertyAsValue(), "Custom permissions", 2048, false),
"A space-separated list of other permission flags that should be added to the manifest.");
}
@@ -1296,6 +1305,12 @@ private:
s.add ("android.permission.ACCESS_COARSE_LOCATION");
}
if (androidExternalReadPermission.get())
s.add ("android.permission.READ_EXTERNAL_STORAGE");
if (androidExternalWritePermission.get())
s.add ("android.permission.WRITE_EXTERNAL_STORAGE");
return getCleanedStringArray (s);
}


+ 2
- 0
extras/Projucer/Source/Utility/jucer_PresetIDs.h View File

@@ -164,6 +164,8 @@ namespace Ids
DECLARE_ID (androidInternetNeeded);
DECLARE_ID (androidArchitectures);
DECLARE_ID (androidBluetoothNeeded);
DECLARE_ID (androidExternalReadNeeded);
DECLARE_ID (androidExternalWriteNeeded);
DECLARE_ID (androidMinimumSDK);
DECLARE_ID (androidOtherPermissions);
DECLARE_ID (androidKeyStore);


+ 6
- 0
modules/juce_core/misc/juce_RuntimePermissions.h View File

@@ -75,6 +75,12 @@ public:
otherwise no devices will be found.
*/
bluetoothMidi = 2,
/** Permission to read from external storage such as SD cards */
readExternalStorage = 3,
/** Permission to write to external storage such as SD cards */
writeExternalStorage = 4
};
//==============================================================================


+ 6
- 2
modules/juce_core/native/java/JuceAppActivity.java View File

@@ -97,13 +97,17 @@ public class JuceAppActivity extends Activity
// these have to match the values of enum PermissionID in C++ class RuntimePermissions:
private static final int JUCE_PERMISSIONS_RECORD_AUDIO = 1;
private static final int JUCE_PERMISSIONS_BLUETOOTH_MIDI = 2;
private static final int JUCE_PERMISSIONS_READ_EXTERNAL_STORAGE = 3;
private static final int JUCE_PERMISSIONS_WRITE_EXTERNAL_STORAGE = 4;
private static String getAndroidPermissionName (int permissionID)
{
switch (permissionID)
{
case JUCE_PERMISSIONS_RECORD_AUDIO: return Manifest.permission.RECORD_AUDIO;
case JUCE_PERMISSIONS_BLUETOOTH_MIDI: return Manifest.permission.ACCESS_COARSE_LOCATION;
case JUCE_PERMISSIONS_RECORD_AUDIO: return Manifest.permission.RECORD_AUDIO;
case JUCE_PERMISSIONS_BLUETOOTH_MIDI: return Manifest.permission.ACCESS_COARSE_LOCATION;
case JUCE_PERMISSIONS_READ_EXTERNAL_STORAGE: return Manifest.permission.READ_EXTERNAL_STORAGE;
case JUCE_PERMISSIONS_WRITE_EXTERNAL_STORAGE: return Manifest.permission.WRITE_EXTERNAL_STORAGE;
}
// unknown permission ID!


Loading…
Cancel
Save