mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Explicitly grant and revoke read permission when playing a track
This commit is contained in:
@@ -25,6 +25,7 @@ import android.content.ContentProvider;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
@@ -423,6 +424,7 @@ public class MyTracksProvider extends ContentProvider {
|
||||
for (File file : dir.listFiles()) {
|
||||
file.delete();
|
||||
}
|
||||
getContext().revokeUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ public class SaveActivity extends Activity {
|
||||
savedPath = aSavedPath;
|
||||
removeDialog(DIALOG_PROGRESS_ID);
|
||||
if (playTrack && successCount == 1 && totalCount == 1 && savedPath != null) {
|
||||
startActivity(GoogleEarthUtils.getPlayInEarthIntent(savedPath));
|
||||
startActivity(GoogleEarthUtils.getPlayInEarthIntent(this, savedPath));
|
||||
finish();
|
||||
} else {
|
||||
showDialog(DIALOG_RESULT_ID);
|
||||
|
||||
@@ -82,9 +82,10 @@ public class GoogleEarthUtils {
|
||||
*
|
||||
* @param kmlFilePath the kml file path
|
||||
*/
|
||||
public static Intent getPlayInEarthIntent(String kmlFilePath) {
|
||||
public static Intent getPlayInEarthIntent(Context context, String kmlFilePath) {
|
||||
Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(MyTracksProviderUtils.AUTHORITY).path(kmlFilePath).build();
|
||||
context.grantUriPermission(GOOGLE_EARTH_PACKAGE, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
return new Intent().addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
.putExtra(GOOGLE_EARTH_TOUR_FEATURE_ID, TOUR_FEATURE_ID_VALUE)
|
||||
|
||||
Reference in New Issue
Block a user