Adding API to get PendingIntent to launch manageSpaceActivity
Bug: 167966131 Test: StorageTestApp and atest StorageManagerTest#testLaunchManageSpaceActivityIntent Change-Id: Id3d23fcca992819238cd24fc441c98719d5e7709 Merged-In: Id3d23fcca992819238cd24fc441c98719d5e7709
This commit is contained in:
@@ -28,6 +28,8 @@ import android.os.storage.StorageVolume;
|
||||
import android.os.storage.VolumeInfo;
|
||||
import android.os.storage.VolumeRecord;
|
||||
import com.android.internal.os.AppFuseMount;
|
||||
import android.app.PendingIntent;
|
||||
|
||||
|
||||
/**
|
||||
* WARNING! Update IMountService.h and IMountService.cpp if you change this
|
||||
@@ -198,4 +200,5 @@ interface IStorageManager {
|
||||
void disableAppDataIsolation(in String pkgName, int pid, int userId) = 90;
|
||||
void notifyAppIoBlocked(in String volumeUuid, int uid, int tid, int reason) = 91;
|
||||
void notifyAppIoResumed(in String volumeUuid, int uid, int tid, int reason) = 92;
|
||||
PendingIntent getManageSpaceActivityIntent(in String packageName, int requestCode) = 93;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import android.app.Activity;
|
||||
import android.app.ActivityThread;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -701,6 +702,33 @@ public class StorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link PendingIntent} that can be used by Apps with
|
||||
* {@link android.Manifest.permission#MANAGE_EXTERNAL_STORAGE} permission
|
||||
* to launch the manageSpaceActivity for any App that implements it, irrespective of its
|
||||
* exported status.
|
||||
* <p>
|
||||
* Caller has the responsibility of supplying a valid packageName which has
|
||||
* manageSpaceActivity implemented.
|
||||
*
|
||||
* @param packageName package name for the App for which manageSpaceActivity is to be launched
|
||||
* @param requestCode for launching the activity
|
||||
* @return PendingIntent to launch the manageSpaceActivity if successful, null if the
|
||||
* packageName doesn't have a manageSpaceActivity.
|
||||
* @throws IllegalArgumentException an invalid packageName is supplied.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.MANAGE_EXTERNAL_STORAGE)
|
||||
@Nullable
|
||||
public PendingIntent getManageSpaceActivityIntent(
|
||||
@NonNull String packageName, int requestCode) {
|
||||
try {
|
||||
return mStorageManager.getManageSpaceActivityIntent(packageName,
|
||||
requestCode);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
private ObbInfo getObbInfo(String canonicalPath) {
|
||||
try {
|
||||
final ObbInfo obbInfo = ObbScanner.getObbInfo(canonicalPath);
|
||||
|
||||
Reference in New Issue
Block a user