Handle android.settings.APPLICATION_DETAILS_SETTINGS

b/19902499

Change-Id: I497040b60375ffcd10e0e2c9dd5130ab5411f708
diff --git a/Settings/AndroidManifest.xml b/Settings/AndroidManifest.xml
index e91ad97..92032fc 100644
--- a/Settings/AndroidManifest.xml
+++ b/Settings/AndroidManifest.xml
@@ -156,7 +156,13 @@
         <activity
             android:name=".device.apps.AppManagementActivity"
             android:configChanges="keyboard|keyboardHidden|navigation"
-            android:exported="true" />
+            android:exported="true" >
+            <intent-filter android:priority="1">
+                <action android:name="android.settings.APPLICATION_DETAILS_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="package" />
+            </intent-filter>
+        </activity>
         <activity
             android:name=".device.StorageResetActivity"
             android:configChanges="keyboard|keyboardHidden|navigation"
diff --git a/Settings/src/com/android/tv/settings/device/apps/AppManagementActivity.java b/Settings/src/com/android/tv/settings/device/apps/AppManagementActivity.java
index 6e788f8..95f1bd9 100644
--- a/Settings/src/com/android/tv/settings/device/apps/AppManagementActivity.java
+++ b/Settings/src/com/android/tv/settings/device/apps/AppManagementActivity.java
@@ -57,9 +57,6 @@
 
     private static final String TAG = "AppManagementActivity";
 
-    private static final String EXTRA_PACKAGE_NAME_KEY = SettingsConstant.PACKAGE
-            + ".device.apps.PACKAGE_NAME";
-
     private static final String DIALOG_BACKSTACK_TAG = "storageUsed";
 
     private static final String SAVE_STATE_MOVE_ID = "AppManagementActivity.moveId";
@@ -112,7 +109,13 @@
         super.onCreate(savedInstanceState);
         mPackageManager = getPackageManager();
         mStorageManager = getSystemService(StorageManager.class);
-        mPackageName = getIntent().getStringExtra(EXTRA_PACKAGE_NAME_KEY);
+        final Uri uri = getIntent().getData();
+        if (uri == null) {
+            Log.e(TAG, "No app to inspect (missing data uri in intent)");
+            finish();
+            return;
+        }
+        mPackageName = uri.getSchemeSpecificPart();
         mApplicationsState = ApplicationsState.getInstance(getApplication());
         mSession = mApplicationsState.newSession(this);
         mSession.resume();
@@ -154,7 +157,7 @@
         Intent i = new Intent();
         i.setComponent(new ComponentName(SettingsConstant.PACKAGE,
                 SettingsConstant.PACKAGE + ".device.apps.AppManagementActivity"));
-        i.putExtra(AppManagementActivity.EXTRA_PACKAGE_NAME_KEY, packageName);
+        i.setData(Uri.parse("package:" + packageName));
         return i;
     }