| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.annotation.SystemService; |
| 21 |
import android.content.Context; |
| 22 |
import android.content.pm.ParceledListSlice; |
| 23 |
import android.os.Handler; |
| 24 |
import android.os.IBinder; |
| 25 |
import android.os.RemoteException; |
| 26 |
import android.os.ServiceManager; |
| 27 |
import android.util.Singleton; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
@SystemService(Context.URI_GRANTS_SERVICE) |
| 35 |
public class UriGrantsManager { |
| 36 |
|
| 37 |
private final Context mContext; |
| 38 |
|
| 39 |
UriGrantsManager(Context context, Handler handler) { |
| 40 |
mContext = context; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
public static IUriGrantsManager getService() { |
| 45 |
return IUriGrantsManagerSingleton.get(); |
| 46 |
} |
| 47 |
|
| 48 |
private static final Singleton<IUriGrantsManager> IUriGrantsManagerSingleton = |
| 49 |
new Singleton<IUriGrantsManager>() { |
| 50 |
@Override |
| 51 |
protected IUriGrantsManager create() { |
| 52 |
final IBinder b = ServiceManager.getService(Context.URI_GRANTS_SERVICE); |
| 53 |
return IUriGrantsManager.Stub.asInterface(b); |
| 54 |
} |
| 55 |
}; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public void clearGrantedUriPermissions(String packageName) { |
| 67 |
try { |
| 68 |
getService().clearGrantedUriPermissions(packageName, mContext.getUserId()); |
| 69 |
} catch (RemoteException e) { |
| 70 |
throw e.rethrowFromSystemServer(); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
public ParceledListSlice<GrantedUriPermission> getGrantedUriPermissions( |
| 87 |
@Nullable String packageName) { |
| 88 |
try { |
| 89 |
@SuppressWarnings("unchecked") |
| 90 |
final ParceledListSlice<GrantedUriPermission> castedList = getService() |
| 91 |
.getGrantedUriPermissions(packageName, mContext.getUserId()); |
| 92 |
return castedList; |
| 93 |
} catch (RemoteException e) { |
| 94 |
throw e.rethrowFromSystemServer(); |
| 95 |
} |
| 96 |
} |
| 97 |
} |