Fix issue #2477264: "Force Stop" in "Manage Applications" is not working

Also add cancel button when adding a device admin.
diff --git a/res/layout/device_admin_add.xml b/res/layout/device_admin_add.xml
index 3ff190b..f560331 100644
--- a/res/layout/device_admin_add.xml
+++ b/res/layout/device_admin_add.xml
@@ -104,5 +104,14 @@
            android:layout_width="0dip"
            android:layout_height="0dip"
            android:layout_weight="1" />
+        <Button android:id="@+id/cancel_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:text="@string/cancel" />
+        <View
+           android:layout_width="0dip"
+           android:layout_height="0dip"
+           android:layout_weight="1" />
     </LinearLayout>
 </LinearLayout>
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java
index d953409..2653e81 100644
--- a/src/com/android/settings/DeviceAdminAdd.java
+++ b/src/com/android/settings/DeviceAdminAdd.java
@@ -64,6 +64,7 @@
     TextView mAdminWarning;
     ViewGroup mAdminPolicies;
     Button mActionButton;
+    Button mCancelButton;
     
     View mSelectLayout;
     
@@ -133,6 +134,12 @@
         mAddMsg = (TextView)findViewById(R.id.add_msg);
         mAdminWarning = (TextView)findViewById(R.id.admin_warning);
         mAdminPolicies = (ViewGroup)findViewById(R.id.admin_policies);
+        mCancelButton = (Button)findViewById(R.id.cancel_button);
+        mCancelButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                finish();
+            }
+        });
         mActionButton = (Button)findViewById(R.id.action_button);
         mActionButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
diff --git a/src/com/android/settings/InstalledAppDetails.java b/src/com/android/settings/InstalledAppDetails.java
index 67f2f8f..128d1cd 100644
--- a/src/com/android/settings/InstalledAppDetails.java
+++ b/src/com/android/settings/InstalledAppDetails.java
@@ -592,6 +592,7 @@
         @Override
         public void onReceive(Context context, Intent intent) {
             mForceStopButton.setEnabled(getResultCode() != RESULT_CANCELED);
+            mForceStopButton.setOnClickListener(InstalledAppDetails.this);
         }
     };
     
@@ -634,13 +635,6 @@
             }
             mPm.deleteApplicationCacheFiles(packageName, mClearCacheObserver);
         } else if (v == mForceStopButton) {
-            // TODO Once framework supports a pre-broadcast to
-            // actually find out if an application will be restarted right
-            // after its killed, there is no way we can determine if
-            // a force stop will really kill the app. So just ignore
-            // the dialog for now and force stop the package. Please note
-            // that the button cannot be enabled or disabled since
-            // we do not have this info for now.
             forceStopPackage(mAppInfo.packageName);
         } else if (v == mMoveAppButton) {
             if (mPackageMoveObserver == null) {