summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-02-27 09:05:10 -0800
committerMike Lockwood <lockwood@android.com>2011-03-01 08:05:59 -0800
commit9d6d92b33ebf1c91aed47bd759ce78a3e06afff5 (patch)
treea3b0c40a6610d9f7f73ec6fbf6eb1faafde1bd6d
parente18897bc2242110782fca135e9e47fcdb5839d64 (diff)
downloadpackages_apps_Settings-9d6d92b33ebf1c91aed47bd759ce78a3e06afff5.tar.gz
packages_apps_Settings-9d6d92b33ebf1c91aed47bd759ce78a3e06afff5.tar.bz2
packages_apps_Settings-9d6d92b33ebf1c91aed47bd759ce78a3e06afff5.zip
InstalledAppDetails: "Clear defaults" button now clears USB service settings
The USB service caches the preferred activity preferences for USB devices and accessories and allows permission to access the hardware based on the user's selection. The "Clear defaults" button can now be used to clear these settings. Change-Id: I307c118cb0ce06362e289e35bca93a47ce4631a5 Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r--AndroidManifest.xml1
-rw-r--r--src/com/android/settings/applications/InstalledAppDetails.java21
2 files changed, 20 insertions, 2 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e092bc904..a8f978774 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -48,6 +48,7 @@
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.STATUS_BAR" />
+ <uses-permission android:name="android.permission.MANAGE_USB" />
<application android:label="@string/settings_label"
android:icon="@mipmap/ic_launcher_settings"
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 06d97fc87..8edf2064e 100644
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -37,13 +37,16 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.hardware.usb.IUsbManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
+import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.preference.PreferenceActivity;
import android.text.format.Formatter;
import android.util.Log;
@@ -79,6 +82,7 @@ public class InstalledAppDetails extends Fragment
public static final String ARG_PACKAGE_NAME = "package";
private PackageManager mPm;
+ private IUsbManager mUsbManager;
private ApplicationsState mState;
private ApplicationsState.AppEntry mAppEntry;
private PackageInfo mPackageInfo;
@@ -305,7 +309,9 @@ public class InstalledAppDetails extends Fragment
mState = ApplicationsState.getInstance(getActivity().getApplication());
mPm = getActivity().getPackageManager();
-
+ IBinder b = ServiceManager.getService(Context.USB_SERVICE);
+ mUsbManager = IUsbManager.Stub.asInterface(b);
+
mCanBeOnSdCardChecker = new CanBeOnSdCardChecker();
}
@@ -444,8 +450,14 @@ public class InstalledAppDetails extends Fragment
List<IntentFilter> intentList = new ArrayList<IntentFilter>();
mPm.getPreferredActivities(intentList, prefActList, packageName);
if(localLOGV) Log.i(TAG, "Have "+prefActList.size()+" number of activities in prefered list");
+ boolean hasUsbDefaults = false;
+ try {
+ hasUsbDefaults = mUsbManager.hasDefaults(packageName, mAppEntry.info.uid);
+ } catch (RemoteException e) {
+ Log.e(TAG, "mUsbManager.hasDefaults", e);
+ }
TextView autoLaunchView = (TextView)mRootView.findViewById(R.id.auto_launch);
- if (prefActList.size() <= 0) {
+ if (prefActList.size() <= 0 && !hasUsbDefaults) {
// Disable clear activities button
autoLaunchView.setText(R.string.auto_launch_disable_text);
mActivitiesButton.setEnabled(false);
@@ -784,6 +796,11 @@ public class InstalledAppDetails extends Fragment
}
} else if(v == mActivitiesButton) {
mPm.clearPackagePreferredActivities(packageName);
+ try {
+ mUsbManager.clearDefaults(packageName, mAppEntry.info.uid);
+ } catch (RemoteException e) {
+ Log.e(TAG, "mUsbManager.clearDefaults", e);
+ }
mActivitiesButton.setEnabled(false);
} else if(v == mClearDataButton) {
if (mAppEntry.info.manageSpaceActivityName != null) {