Class MAMFileProtectionManager

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static void protect(@NonNull() File file, @NonNull() String identity) Protect a file or directory.
      static void protectForOID(@NonNull() File file, @NonNull() String oid) Protect a file or directory.
      static void protect(@NonNull() ParcelFileDescriptor file, @NonNull() String identity) Protect a file, generally one obtained from a content provider.
      static void protectForOID(@NonNull() ParcelFileDescriptor file, @NonNull() String oid) Protect a file, generally one obtained from a content provider.
      static MAMFileProtectionInfo getProtectionInfo(@NonNull() File file) Get the protection info on a file.
      static MAMFileProtectionInfo getProtectionInfo(@NonNull() ParcelFileDescriptor file) Get the protection info on a file descriptor.
      static MAMFileProtectionInfo getProtectionInfo(Uri uri) Get the protection info on a file accessed via a content URI.
      static boolean isBackupAllowed(@NonNull() File file) Determines whether a file is allowed to be backed up or not.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • protect

        @Deprecated() static void protect(@NonNull() File file, @NonNull() String identity)

        Protect a file or directory. This will synchronously trigger whatever protection is required for the file, and will tag the file for future protection changes. If an identity is set on a directory, it is set recursively on all files and subdirectories. New files or directories will inherit their parent directory's identity. This method will silently do nothing (neither change an identity nor throw) in the following conditions:

        • MAM is operating in offline mode
        • The file is exempted from MAM file protection (such as .so and .apk files)
        Parameters:
        file - File to protect.
        identity - UPN of the identity to set.
      • protectForOID

         static void protectForOID(@NonNull() File file, @NonNull() String oid)

        Protect a file or directory. This will synchronously trigger whatever protection is required for the file, and will tag the file for future protection changes. If an identity is set on a directory, it is set recursively on all files and subdirectories. New files or directories will inherit their parent directory's identity. This method will silently do nothing (neither change an identity nor throw) in the following conditions:

        • MAM is operating in offline mode
        • The file is exempted from MAM file protection (such as .so and .apk files)
        Parameters:
        file - File to protect.
        oid - AAD OID of the identity to set.
      • protect

        @Deprecated() static void protect(@NonNull() ParcelFileDescriptor file, @NonNull() String identity)

        Protect a file, generally one obtained from a content provider. This is intended to be used for sdcard (whether internal or removable) files accessed through the Storage Access Framework. It may also be used with descriptors referring to private files owned by this app. It is not intended to be used for files owned by other apps and such usage will fail. If creating a new file via a content provider exposed by another MAM-integrated app, the new file identity will automatically be set correctly if the ContentResolver in use was obtained via a Context with an identity or if the thread identity is set.

        This will synchronously trigger whatever protection is required for the file, and will tag the file for future protection changes. If an identity is set on a directory, it is set recursively on all files and subdirectories. If MAM is operating in offline mode, this method will silently do nothing.

        Parameters:
        file - File to protect.
        identity - UPN of identity to set.
      • protectForOID

         static void protectForOID(@NonNull() ParcelFileDescriptor file, @NonNull() String oid)

        Protect a file, generally one obtained from a content provider. This is intended to be used for sdcard (whether internal or removable) files accessed through the Storage Access Framework. It may also be used with descriptors referring to private files owned by this app. It is not intended to be used for files owned by other apps and such usage will fail. If creating a new file via a content provider exposed by another MAM-integrated app, the new file identity will automatically be set correctly if the ContentResolver in use was obtained via a Context with an identity or if the thread identity is set.

        This will synchronously trigger whatever protection is required for the file, and will tag the file for future protection changes. If an identity is set on a directory, it is set recursively on all files and subdirectories. If MAM is operating in offline mode, this method will silently do nothing.

        Parameters:
        file - File to protect.
        oid - AAD OID of identity to set.
      • getProtectionInfo

        @Nullable() static MAMFileProtectionInfo getProtectionInfo(@NonNull() File file)

        Get the protection info on a file. This method should only be used if the file is located in the calling application's private storage or the device's shared storage. If opening a file with a content resolver, use the overload which takes a ParcelFileDescriptor instead.

        Parameters:
        file - File or directory to get information on.
        Returns:

        File protection info or null if there was no protection info available on the file.

      • getProtectionInfo

        @Nullable() static MAMFileProtectionInfo getProtectionInfo(@NonNull() ParcelFileDescriptor file)

        Get the protection info on a file descriptor. If opening a file through a ContentResolver, prefer the overload taking a Uri, below.

        Parameters:
        file - Handle of file or directory to get information on.
        Returns:

        File protection info, or null if there is no protection info.

      • getProtectionInfo

        @Nullable() static MAMFileProtectionInfo getProtectionInfo(Uri uri)

        Get the protection info on a file accessed via a content URI. This call will always be able to retrieve the identity (if there is one), even if opening a file descriptor or InputStream on the content URI would be blocked by policy. It should therefore be preferred when checking the identity of a file that will be read from a ContentResolver.

        Parameters:
        uri - Content URI.
        Returns:

        File protection info, or null if there is no protection info.

      • isBackupAllowed

         static boolean isBackupAllowed(@NonNull() File file)

        Determines whether a file is allowed to be backed up or not.

        Parameters:
        file - the file to check.
        Returns:

        true if the file can be backed up, false if not.