Merge "Fix 2579461 Disable move when manifest option for install location is unspecified and install location is auto/internal" into froyo
This commit is contained in:
committed by
Android (Google) Code Review
commit
3a95f92650
@@ -62,7 +62,7 @@ public class ApplicationSettings extends PreferenceActivity implements
|
|||||||
mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
|
mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
|
||||||
// Is app default install location set?
|
// Is app default install location set?
|
||||||
boolean userSetInstLocation = (Settings.System.getInt(getContentResolver(),
|
boolean userSetInstLocation = (Settings.System.getInt(getContentResolver(),
|
||||||
Settings.System.SET_INSTALL_LOCATION, 0) != 0);
|
Settings.Secure.SET_INSTALL_LOCATION, 0) != 0);
|
||||||
if (!userSetInstLocation) {
|
if (!userSetInstLocation) {
|
||||||
getPreferenceScreen().removePreference(mInstallLocation);
|
getPreferenceScreen().removePreference(mInstallLocation);
|
||||||
} else {
|
} else {
|
||||||
@@ -86,17 +86,17 @@ public class ApplicationSettings extends PreferenceActivity implements
|
|||||||
protected void handleUpdateAppInstallLocation(final String value) {
|
protected void handleUpdateAppInstallLocation(final String value) {
|
||||||
if(APP_INSTALL_DEVICE_ID.equals(value)) {
|
if(APP_INSTALL_DEVICE_ID.equals(value)) {
|
||||||
Settings.System.putInt(getContentResolver(),
|
Settings.System.putInt(getContentResolver(),
|
||||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_DEVICE);
|
Settings.Secure.DEFAULT_INSTALL_LOCATION, APP_INSTALL_DEVICE);
|
||||||
} else if (APP_INSTALL_SDCARD_ID.equals(value)) {
|
} else if (APP_INSTALL_SDCARD_ID.equals(value)) {
|
||||||
Settings.System.putInt(getContentResolver(),
|
Settings.System.putInt(getContentResolver(),
|
||||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_SDCARD);
|
Settings.Secure.DEFAULT_INSTALL_LOCATION, APP_INSTALL_SDCARD);
|
||||||
} else if (APP_INSTALL_AUTO_ID.equals(value)) {
|
} else if (APP_INSTALL_AUTO_ID.equals(value)) {
|
||||||
Settings.System.putInt(getContentResolver(),
|
Settings.System.putInt(getContentResolver(),
|
||||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
|
Settings.Secure.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
|
||||||
} else {
|
} else {
|
||||||
// Should not happen, default to prompt...
|
// Should not happen, default to prompt...
|
||||||
Settings.System.putInt(getContentResolver(),
|
Settings.System.putInt(getContentResolver(),
|
||||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
|
Settings.Secure.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
|
||||||
}
|
}
|
||||||
mInstallLocation.setValue(value);
|
mInstallLocation.setValue(value);
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ public class ApplicationSettings extends PreferenceActivity implements
|
|||||||
|
|
||||||
private String getAppInstallLocation() {
|
private String getAppInstallLocation() {
|
||||||
int selectedLocation = Settings.System.getInt(getContentResolver(),
|
int selectedLocation = Settings.System.getInt(getContentResolver(),
|
||||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
|
Settings.Secure.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
|
||||||
if (selectedLocation == APP_INSTALL_DEVICE) {
|
if (selectedLocation == APP_INSTALL_DEVICE) {
|
||||||
return APP_INSTALL_DEVICE_ID;
|
return APP_INSTALL_DEVICE_ID;
|
||||||
} else if (selectedLocation == APP_INSTALL_SDCARD) {
|
} else if (selectedLocation == APP_INSTALL_SDCARD) {
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import com.android.internal.content.PackageHelper;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
@@ -30,6 +31,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.IPackageDataObserver;
|
import android.content.pm.IPackageDataObserver;
|
||||||
|
import android.content.pm.IPackageManager;
|
||||||
import android.content.pm.IPackageMoveObserver;
|
import android.content.pm.IPackageMoveObserver;
|
||||||
import android.content.pm.IPackageStatsObserver;
|
import android.content.pm.IPackageStatsObserver;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
@@ -40,8 +42,11 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.ServiceManager;
|
||||||
|
import android.os.storage.IMountService;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -230,17 +235,36 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
|
|||||||
mMoveAppButton.setText(R.string.move_app);
|
mMoveAppButton.setText(R.string.move_app);
|
||||||
} else if ((mAppInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
|
} else if ((mAppInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
|
||||||
mMoveAppButton.setText(R.string.move_app_to_internal);
|
mMoveAppButton.setText(R.string.move_app_to_internal);
|
||||||
|
// Always let apps move to internal storage from sdcard.
|
||||||
moveDisable = false;
|
moveDisable = false;
|
||||||
} else {
|
} else {
|
||||||
moveDisable = (mAppInfo.flags & ApplicationInfo.FLAG_FORWARD_LOCK) != 0 ||
|
|
||||||
(mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
|
||||||
mMoveAppButton.setText(R.string.move_app_to_sdcard);
|
mMoveAppButton.setText(R.string.move_app_to_sdcard);
|
||||||
}
|
if ((mAppInfo.flags & ApplicationInfo.FLAG_FORWARD_LOCK) != 0 ||
|
||||||
if (pkgInfo != null && pkgInfo.installLocation ==
|
(mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||||
PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY) {
|
moveDisable = true;
|
||||||
// If an application explicitly specifies install location
|
} else if (pkgInfo != null) {
|
||||||
// consider that
|
if (pkgInfo.installLocation ==
|
||||||
moveDisable = true;
|
PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY) {
|
||||||
|
// If an application explicitly specifies install location
|
||||||
|
// consider that
|
||||||
|
moveDisable = true;
|
||||||
|
} else if (pkgInfo.installLocation == PackageInfo.INSTALL_LOCATION_UNSPECIFIED) {
|
||||||
|
IPackageManager ipm = IPackageManager.Stub.asInterface(
|
||||||
|
ServiceManager.getService("package"));
|
||||||
|
int loc;
|
||||||
|
try {
|
||||||
|
loc = ipm.getInstallLocation();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "Is Pakage Manager running?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (loc == PackageHelper.APP_INSTALL_EXTERNAL) {
|
||||||
|
// For apps with no preference and the default value set
|
||||||
|
// to install on sdcard.
|
||||||
|
moveDisable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (moveDisable) {
|
if (moveDisable) {
|
||||||
mMoveAppButton.setEnabled(false);
|
mMoveAppButton.setEnabled(false);
|
||||||
|
Reference in New Issue
Block a user