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

Also add cancel button when adding a device admin.
This commit is contained in:
Dianne Hackborn
2010-03-03 17:18:13 -08:00
parent 65daa5f593
commit 97de6bccfe
3 changed files with 17 additions and 7 deletions

View File

@@ -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>

View File

@@ -64,6 +64,7 @@ public class DeviceAdminAdd extends Activity {
TextView mAdminWarning;
ViewGroup mAdminPolicies;
Button mActionButton;
Button mCancelButton;
View mSelectLayout;
@@ -133,6 +134,12 @@ public class DeviceAdminAdd extends Activity {
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) {

View File

@@ -592,6 +592,7 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
@Override
public void onReceive(Context context, Intent intent) {
mForceStopButton.setEnabled(getResultCode() != RESULT_CANCELED);
mForceStopButton.setOnClickListener(InstalledAppDetails.this);
}
};
@@ -634,13 +635,6 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
}
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) {