summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/InstallAppConfirmation.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/packageinstaller/InstallAppConfirmation.java')
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppConfirmation.java109
1 files changed, 109 insertions, 0 deletions
diff --git a/src/com/android/packageinstaller/InstallAppConfirmation.java b/src/com/android/packageinstaller/InstallAppConfirmation.java
new file mode 100755
index 00000000..eebe8b59
--- /dev/null
+++ b/src/com/android/packageinstaller/InstallAppConfirmation.java
@@ -0,0 +1,109 @@
+/*
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+package com.android.packageinstaller;
+
+import com.android.packageinstaller.R;
+import java.util.ArrayList;
+import android.widget.AppSecurityPermissions;
+import android.app.Activity;
+import android.content.pm.PermissionInfo;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+/**
+ * This activity corresponds to a confirmation screen that is displayed when the user tries
+ * to install an application bundled as an apk file.
+ * The intent that launches this activity should include the application information object
+ * of the application(to be installed) and a list of permission strings associated
+ * with the application. This information is displayed on the screen and installation is either
+ * continued or canceled based on the user response(click ok or cancel).
+ */
+public class InstallAppConfirmation extends Activity implements View.OnClickListener {
+ private final String TAG="InstallAppConfirmation";
+ private boolean localLOGV = false;
+ private Button mOk;
+ private Button mCancel;
+ private ApplicationInfo mAppInfo;
+ private Uri mPkgURI;
+ private View mContentView;
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ Intent intent = getIntent();
+ if(localLOGV) Log.i(TAG, "intent="+intent);
+ mAppInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
+ mPkgURI = intent.getData();
+ if(localLOGV) Log.i(TAG, "mAppInfo = "+mAppInfo);
+ initView();
+ }
+
+ public void initView() {
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ String unknown = getString(R.string.unknown);
+ //set description
+ String desc = getString(R.string.security_settings_desc);
+ if(desc == null) {
+ desc = unknown;
+ }
+ LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mContentView = inflater.inflate(R.layout.install_confirm, null);
+ setContentView(mContentView);
+ //initialize views
+ PackageUtil.initAppSnippet(this, mAppInfo, R.id.app_snippet);
+ if(desc != null) {
+ ((TextView)findViewById(R.id.security_settings_desc)).setText(desc);
+ }
+ //set permissions
+ AppSecurityPermissions asp = new AppSecurityPermissions(this);
+ asp.setSecurityPermissionsView(mPkgURI);
+ LinearLayout securityList = (LinearLayout) mContentView.findViewById(R.id.security_settings_list);
+ securityList.addView(asp.getPermissionsView());
+ mOk = (Button)findViewById(R.id.ok_button);
+ mCancel = (Button)findViewById(R.id.cancel_button);
+ mOk.setOnClickListener(this);
+ mCancel.setOnClickListener(this);
+ }
+
+ public void setResultAndReturn(int result) {
+ if(result == RESULT_CANCELED) Log.i(TAG, "Result has been canceled");
+ if(result == RESULT_OK) Log.i(TAG, "result ok");
+ setResult(result);
+ finish();
+ }
+
+ public void onClick(View v) {
+ int result = RESULT_CANCELED;
+ if(v == mOk) {
+ result = RESULT_OK;
+ setResultAndReturn(result);
+ } else if(v == mCancel) {
+ result = RESULT_CANCELED;
+ setResultAndReturn(result);
+ }
+ }
+}