下面列出了android.content.pm.PackageInfo#INSTALL_LOCATION_INTERNAL_ONLY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static boolean isPackageCandidateVolume(ApplicationInfo app, VolumeInfo vol) {
// Private internal is always an option
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())) {
return true;
}
// System apps and apps demanding internal storage can't be moved
// anywhere else
if (app.isSystemApp()
|| app.installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY
|| app.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED) {
return false;
}
// Gotta be able to write there
if (!vol.isMountedWritable()) {
return false;
}
// Moving into an ASEC on public primary is only option internal
if (vol.isPrimaryPhysical()) {
return app.isInternal();
}
// Otherwise we can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}
public static String translatePMInstallLocation(int installLocationType) {
switch (installLocationType) {
case PackageInfo.INSTALL_LOCATION_AUTO:
return "AUTO";
case PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY:
return "INTERNAL_ONLY";
case PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL:
return "PREFER_EXTERNAL";
case -1:
return "UNSPECIFIED";
default:
return "UNKNOWN (" + installLocationType + ")";
}
}
private boolean isPackageCandidateVolume(
ContextImpl context, ApplicationInfo app, VolumeInfo vol) {
final boolean forceAllowOnExternal = Settings.Global.getInt(
context.getContentResolver(), Settings.Global.FORCE_ALLOW_ON_EXTERNAL, 0) != 0;
// Private internal is always an option
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())) {
return true;
}
// System apps and apps demanding internal storage can't be moved
// anywhere else
if (app.isSystemApp()) {
return false;
}
if (!forceAllowOnExternal
&& (app.installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY
|| app.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED)) {
return false;
}
// Gotta be able to write there
if (!vol.isMountedWritable()) {
return false;
}
// Moving into an ASEC on public primary is only option internal
if (vol.isPrimaryPhysical()) {
return app.isInternal();
}
// Some apps can't be moved. (e.g. device admins)
try {
if (mPM.isPackageDeviceAdminOnAnyUser(app.packageName)) {
return false;
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// Otherwise we can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}
private boolean isPackageCandidateVolume(
ContextImpl context, ApplicationInfo app, VolumeInfo vol, IPackageManager pm) {
final boolean forceAllowOnExternal = isForceAllowOnExternal(context);
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())) {
return app.isSystemApp() || isAllow3rdPartyOnInternal(context);
}
// System apps and apps demanding internal storage can't be moved
// anywhere else
if (app.isSystemApp()) {
return false;
}
if (!forceAllowOnExternal
&& (app.installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY
|| app.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED)) {
return false;
}
// Gotta be able to write there
if (!vol.isMountedWritable()) {
return false;
}
// Moving into an ASEC on public primary is only option internal
if (vol.isPrimaryPhysical()) {
return app.isInternal();
}
// Some apps can't be moved. (e.g. device admins)
try {
if (pm.isPackageDeviceAdminOnAnyUser(app.packageName)) {
return false;
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// Otherwise we can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}
private boolean isPackageCandidateVolume(
ContextImpl context, ApplicationInfo app, VolumeInfo vol, IPackageManager pm) {
final boolean forceAllowOnExternal = isForceAllowOnExternal(context);
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())) {
return app.isSystemApp() || isAllow3rdPartyOnInternal(context);
}
// System apps and apps demanding internal storage can't be moved
// anywhere else
if (app.isSystemApp()) {
return false;
}
if (!forceAllowOnExternal
&& (app.installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY
|| app.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED)) {
return false;
}
// Gotta be able to write there
if (!vol.isMountedWritable()) {
return false;
}
// Moving into an ASEC on public primary is only option internal
if (vol.isPrimaryPhysical()) {
return app.isInternal();
}
// Some apps can't be moved. (e.g. device admins)
try {
if (pm.isPackageDeviceAdminOnAnyUser(app.packageName)) {
return false;
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// Otherwise we can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}
private boolean isPackageCandidateVolume(
ContextImpl context, ApplicationInfo app, VolumeInfo vol, IPackageManager pm) {
final boolean forceAllowOnExternal = isForceAllowOnExternal(context);
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())) {
return app.isSystemApp() || isAllow3rdPartyOnInternal(context);
}
// System apps and apps demanding internal storage can't be moved
// anywhere else
if (app.isSystemApp()) {
return false;
}
if (!forceAllowOnExternal
&& (app.installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY
|| app.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED)) {
return false;
}
// Gotta be able to write there
if (!vol.isMountedWritable()) {
return false;
}
// Moving into an ASEC on public primary is only option internal
if (vol.isPrimaryPhysical()) {
return app.isInternal();
}
// Some apps can't be moved. (e.g. device admins)
try {
if (pm.isPackageDeviceAdminOnAnyUser(app.packageName)) {
return false;
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// Otherwise we can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}
private boolean isPackageCandidateVolume(
ContextImpl context, ApplicationInfo app, VolumeInfo vol, IPackageManager pm) {
final boolean forceAllowOnExternal = isForceAllowOnExternal(context);
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())) {
return app.isSystemApp() || isAllow3rdPartyOnInternal(context);
}
// System apps and apps demanding internal storage can't be moved
// anywhere else
if (app.isSystemApp()) {
return false;
}
if (!forceAllowOnExternal
&& (app.installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY
|| app.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED)) {
return false;
}
// Gotta be able to write there
if (!vol.isMountedWritable()) {
return false;
}
// Moving into an ASEC on public primary is only option internal
if (vol.isPrimaryPhysical()) {
return app.isInternal();
}
// Some apps can't be moved. (e.g. device admins)
try {
if (pm.isPackageDeviceAdminOnAnyUser(app.packageName)) {
return false;
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// Otherwise we can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}
private boolean isPackageCandidateVolume(
ContextImpl context, ApplicationInfo app, VolumeInfo vol, IPackageManager pm) {
final boolean forceAllowOnExternal = isForceAllowOnExternal(context);
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())) {
return app.isSystemApp() || isAllow3rdPartyOnInternal(context);
}
// System apps and apps demanding internal storage can't be moved
// anywhere else
if (app.isSystemApp()) {
return false;
}
if (!forceAllowOnExternal
&& (app.installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY
|| app.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED)) {
return false;
}
// Gotta be able to write there
if (!vol.isMountedWritable()) {
return false;
}
// Moving into an ASEC on public primary is only option internal
if (vol.isPrimaryPhysical()) {
return app.isInternal();
}
// Some apps can't be moved. (e.g. device admins)
try {
if (pm.isPackageDeviceAdminOnAnyUser(app.packageName)) {
return false;
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// Otherwise we can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}
private boolean isPackageCandidateVolume(
ContextImpl context, ApplicationInfo app, VolumeInfo vol) {
final boolean forceAllowOnExternal = Settings.Global.getInt(
context.getContentResolver(), Settings.Global.FORCE_ALLOW_ON_EXTERNAL, 0) != 0;
// Private internal is always an option
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())) {
return true;
}
// System apps and apps demanding internal storage can't be moved
// anywhere else
if (app.isSystemApp()) {
return false;
}
if (!forceAllowOnExternal
&& (app.installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY
|| app.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED)) {
return false;
}
// Gotta be able to write there
if (!vol.isMountedWritable()) {
return false;
}
// Moving into an ASEC on public primary is only option internal
if (vol.isPrimaryPhysical()) {
return app.isInternal();
}
// Some apps can't be moved. (e.g. device admins)
try {
if (mPM.isPackageDeviceAdminOnAnyUser(app.packageName)) {
return false;
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// Otherwise we can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}
private boolean isPackageCandidateVolume(
ContextImpl context, ApplicationInfo app, VolumeInfo vol, IPackageManager pm) {
final boolean forceAllowOnExternal = isForceAllowOnExternal(context);
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())) {
return app.isSystemApp() || isAllow3rdPartyOnInternal(context);
}
// System apps and apps demanding internal storage can't be moved
// anywhere else
if (app.isSystemApp()) {
return false;
}
if (!forceAllowOnExternal
&& (app.installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY
|| app.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED)) {
return false;
}
// Gotta be able to write there
if (!vol.isMountedWritable()) {
return false;
}
// Moving into an ASEC on public primary is only option internal
if (vol.isPrimaryPhysical()) {
return app.isInternal();
}
// Some apps can't be moved. (e.g. device admins)
try {
if (pm.isPackageDeviceAdminOnAnyUser(app.packageName)) {
return false;
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// Otherwise we can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}