-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tool: enable/disable scoped storage
A script to enable/disable scoped storage without the need to uninstall/upgrade from `targetSdkVersion 29` Makes testing of the disable/enable routine quicker Issue #5304
- Loading branch information
1 parent
7e9769d
commit fb856da
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#/bin/bash | ||
# enable/disable scoped storage: ./set_scoped_storage.sh [limited/full] | ||
|
||
|
||
function help() { | ||
echo "\nArguments:" | ||
echo "limited\t\tEquivalent to a fresh install. /AnkiDroid/ is inaccessible" | ||
echo "full\t\tEquivalent to an upgrade from targetSdkVersion 29 to 30. /AnkiDroid/ is accessible\n" | ||
} | ||
|
||
# This should be run when a single AOSP emulator is open. | ||
# Errors are suppressed by default. Remove > /dev/null | ||
if [ "$1" = "full" ]; then | ||
adb shell pm grant com.ichi2.anki.debug android.permission.READ_EXTERNAL_STORAGE | ||
adb shell pm grant com.ichi2.anki.debug android.permission.WRITE_EXTERNAL_STORAGE | ||
adb shell am compat disable FORCE_ENABLE_SCOPED_STORAGE com.ichi2.anki.debug > /dev/null | ||
adb shell am compat disable DEFAULT_SCOPED_STORAGE com.ichi2.anki.debug > /dev/null # fails on Play store | ||
if [ $? == '0' ]; then | ||
echo "scoped storage disabled: preserving storage access" | ||
else | ||
echo "something went wrong: edit script to display errors" | ||
fi | ||
elif [ "$1" = "limited" ]; then | ||
adb shell pm revoke com.ichi2.anki.debug android.permission.READ_EXTERNAL_STORAGE | ||
adb shell pm revoke com.ichi2.anki.debug android.permission.WRITE_EXTERNAL_STORAGE | ||
adb shell am compat enable FORCE_ENABLE_SCOPED_STORAGE com.ichi2.anki.debug > /dev/null | ||
adb shell am compat enable DEFAULT_SCOPED_STORAGE com.ichi2.anki.debug > /dev/null | ||
if [ $? == '0' ]; then | ||
echo "scoped storage enabled: storage access disabled" | ||
else | ||
echo "something went wrong: edit script to display errors" | ||
fi | ||
elif [ "$1" = "" ]; then | ||
echo "First argument missing." | ||
help | ||
else | ||
echo "unknown argument: '$1'. Valid values: 'limited', 'full'" | ||
help | ||
fi | ||
|
||
|
||
# future extension: have an argument trigger the 'permission revoked' state by changing 'deckPath' | ||
# while storage is 'limited' |