Manage apps "on SD card" now shows all apps that can go on SD card.
Change-Id: Icc413891b2b884bb1af340b4c09ab3935c8e51ca
This commit is contained in:
@@ -37,7 +37,8 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0px"
|
||||||
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="wrap_content" >
|
||||||
<TextView android:id="@+id/app_name"
|
<TextView android:id="@+id/app_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -70,5 +71,13 @@
|
|||||||
android:text="@string/disabled" />
|
android:text="@string/disabled" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<CheckBox android:id="@+id/app_on_sdcard"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dip"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@@ -49,6 +49,7 @@ public class ApplicationsState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static interface AppFilter {
|
public static interface AppFilter {
|
||||||
|
public void init();
|
||||||
public boolean filterApp(ApplicationInfo info);
|
public boolean filterApp(ApplicationInfo info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +120,9 @@ public class ApplicationsState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static final AppFilter THIRD_PARTY_FILTER = new AppFilter() {
|
public static final AppFilter THIRD_PARTY_FILTER = new AppFilter() {
|
||||||
|
public void init() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filterApp(ApplicationInfo info) {
|
public boolean filterApp(ApplicationInfo info) {
|
||||||
if ((info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
|
if ((info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
|
||||||
@@ -131,12 +135,16 @@ public class ApplicationsState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static final AppFilter ON_SD_CARD_FILTER = new AppFilter() {
|
public static final AppFilter ON_SD_CARD_FILTER = new AppFilter() {
|
||||||
|
final CanBeOnSdCardChecker mCanBeOnSdCardChecker
|
||||||
|
= new CanBeOnSdCardChecker();
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
mCanBeOnSdCardChecker.init();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filterApp(ApplicationInfo info) {
|
public boolean filterApp(ApplicationInfo info) {
|
||||||
if ((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
|
return mCanBeOnSdCardChecker.check(info);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -367,6 +375,10 @@ public class ApplicationsState {
|
|||||||
|
|
||||||
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
|
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
|
||||||
|
|
||||||
|
if (filter != null) {
|
||||||
|
filter.init();
|
||||||
|
}
|
||||||
|
|
||||||
List<ApplicationInfo> apps;
|
List<ApplicationInfo> apps;
|
||||||
synchronized (mEntriesMap) {
|
synchronized (mEntriesMap) {
|
||||||
apps = new ArrayList<ApplicationInfo>(mApplications);
|
apps = new ArrayList<ApplicationInfo>(mApplications);
|
||||||
|
@@ -77,6 +77,7 @@ public class InstalledAppDetails extends Activity
|
|||||||
private ApplicationsState mState;
|
private ApplicationsState mState;
|
||||||
private ApplicationsState.AppEntry mAppEntry;
|
private ApplicationsState.AppEntry mAppEntry;
|
||||||
private PackageInfo mPackageInfo;
|
private PackageInfo mPackageInfo;
|
||||||
|
private CanBeOnSdCardChecker mCanBeOnSdCardChecker;
|
||||||
private Button mUninstallButton;
|
private Button mUninstallButton;
|
||||||
private boolean mMoveInProgress = false;
|
private boolean mMoveInProgress = false;
|
||||||
private boolean mUpdatedSysApp = false;
|
private boolean mUpdatedSysApp = false;
|
||||||
@@ -229,30 +230,8 @@ public class InstalledAppDetails extends Activity
|
|||||||
moveDisable = false;
|
moveDisable = false;
|
||||||
} else {
|
} else {
|
||||||
mMoveAppButton.setText(R.string.move_app_to_sdcard);
|
mMoveAppButton.setText(R.string.move_app_to_sdcard);
|
||||||
if ((mAppEntry.info.flags & ApplicationInfo.FLAG_FORWARD_LOCK) == 0 &&
|
mCanBeOnSdCardChecker.init();
|
||||||
(mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) == 0 &&
|
moveDisable = !mCanBeOnSdCardChecker.check(mAppEntry.info);
|
||||||
mPackageInfo != null) {
|
|
||||||
if (mPackageInfo.installLocation == PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL ||
|
|
||||||
mPackageInfo.installLocation == PackageInfo.INSTALL_LOCATION_AUTO) {
|
|
||||||
moveDisable = false;
|
|
||||||
} else if (mPackageInfo.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);
|
||||||
@@ -316,6 +295,8 @@ public class InstalledAppDetails extends Activity
|
|||||||
mState = ApplicationsState.getInstance(getApplication());
|
mState = ApplicationsState.getInstance(getApplication());
|
||||||
mPm = getPackageManager();
|
mPm = getPackageManager();
|
||||||
|
|
||||||
|
mCanBeOnSdCardChecker = new CanBeOnSdCardChecker();
|
||||||
|
|
||||||
setContentView(R.layout.installed_app_details);
|
setContentView(R.layout.installed_app_details);
|
||||||
|
|
||||||
mComputingStr = getText(R.string.computing_size);
|
mComputingStr = getText(R.string.computing_size);
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
|
import com.android.internal.content.PackageHelper;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.applications.ApplicationsState.AppEntry;
|
import com.android.settings.applications.ApplicationsState.AppEntry;
|
||||||
|
|
||||||
@@ -24,8 +25,12 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.IPackageManager;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.RemoteException;
|
||||||
|
import android.os.ServiceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -38,6 +43,7 @@ import android.view.animation.AnimationUtils;
|
|||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@@ -50,6 +56,48 @@ import java.util.ArrayList;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
final class CanBeOnSdCardChecker {
|
||||||
|
final IPackageManager mPm;
|
||||||
|
int mInstallLocation;
|
||||||
|
|
||||||
|
CanBeOnSdCardChecker() {
|
||||||
|
mPm = IPackageManager.Stub.asInterface(
|
||||||
|
ServiceManager.getService("package"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
try {
|
||||||
|
mInstallLocation = mPm.getInstallLocation();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e("CanBeOnSdCardChecker", "Is Package Manager running?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean check(ApplicationInfo info) {
|
||||||
|
boolean canBe = false;
|
||||||
|
if ((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
|
||||||
|
canBe = true;
|
||||||
|
} else {
|
||||||
|
if ((info.flags & ApplicationInfo.FLAG_FORWARD_LOCK) == 0 &&
|
||||||
|
(info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||||
|
if (info.installLocation == PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL ||
|
||||||
|
info.installLocation == PackageInfo.INSTALL_LOCATION_AUTO) {
|
||||||
|
canBe = true;
|
||||||
|
} else if (info.installLocation
|
||||||
|
== PackageInfo.INSTALL_LOCATION_UNSPECIFIED) {
|
||||||
|
if (mInstallLocation == PackageHelper.APP_INSTALL_EXTERNAL) {
|
||||||
|
// For apps with no preference and the default value set
|
||||||
|
// to install on sdcard.
|
||||||
|
canBe = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return canBe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity to pick an application that will be used to display installation information and
|
* Activity to pick an application that will be used to display installation information and
|
||||||
* options to uninstall/delete user data for system applications. This activity
|
* options to uninstall/delete user data for system applications. This activity
|
||||||
@@ -125,6 +173,7 @@ public class ManageApplications extends TabActivity implements
|
|||||||
ImageView appIcon;
|
ImageView appIcon;
|
||||||
TextView appSize;
|
TextView appSize;
|
||||||
TextView disabled;
|
TextView disabled;
|
||||||
|
CheckBox checkBox;
|
||||||
|
|
||||||
void updateSizeText(ManageApplications ma) {
|
void updateSizeText(ManageApplications ma) {
|
||||||
if (DEBUG) Log.i(TAG, "updateSizeText of " + entry.label + " " + entry
|
if (DEBUG) Log.i(TAG, "updateSizeText of " + entry.label + " " + entry
|
||||||
@@ -364,6 +413,7 @@ public class ManageApplications extends TabActivity implements
|
|||||||
holder.appIcon = (ImageView) convertView.findViewById(R.id.app_icon);
|
holder.appIcon = (ImageView) convertView.findViewById(R.id.app_icon);
|
||||||
holder.appSize = (TextView) convertView.findViewById(R.id.app_size);
|
holder.appSize = (TextView) convertView.findViewById(R.id.app_size);
|
||||||
holder.disabled = (TextView) convertView.findViewById(R.id.app_disabled);
|
holder.disabled = (TextView) convertView.findViewById(R.id.app_disabled);
|
||||||
|
holder.checkBox = (CheckBox) convertView.findViewById(R.id.app_on_sdcard);
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
// Get the ViewHolder back to get fast access to the TextView
|
// Get the ViewHolder back to get fast access to the TextView
|
||||||
@@ -391,6 +441,13 @@ public class ManageApplications extends TabActivity implements
|
|||||||
} else {
|
} else {
|
||||||
holder.disabled.setVisibility(View.GONE);
|
holder.disabled.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
if (mLastFilterMode == FILTER_APPS_SDCARD) {
|
||||||
|
holder.checkBox.setVisibility(View.VISIBLE);
|
||||||
|
holder.checkBox.setChecked((entry.info.flags
|
||||||
|
& ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0);
|
||||||
|
} else {
|
||||||
|
holder.checkBox.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mActive.remove(convertView);
|
mActive.remove(convertView);
|
||||||
mActive.add(convertView);
|
mActive.add(convertView);
|
||||||
|
Reference in New Issue
Block a user