/*
**
** 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 android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageParser;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AppSecurityPermissions;
import android.widget.Button;
import android.widget.LinearLayout;
/*
* This activity is launched when a new application is installed via side loading
* The package is first parsed and the user is notified of parse errors via a dialog.
* If the package is successfully parsed, the user is notified to turn on the install unknown
* applications setting. A memory check is made at this point and the user is notified of out
* of memory conditions if any. If the package is already existing on the device,
* a confirmation dialog (to replace the existing package) is presented to the user.
* Based on the user response the package is then installed by launching InstallAppConfirm
* sub activity. All state transitions are handled in this activity
*/
public class PackageInstallerActivity extends Activity implements OnCancelListener, OnClickListener {
private static final String TAG = "PackageInstaller";
private Uri mPackageURI;
private boolean localLOGV = false;
PackageManager mPm;
PackageParser.Package mPkgInfo;
ApplicationInfo mSourceInfo;
// ApplicationInfo object primarily used for already existing applications
private ApplicationInfo mAppInfo = null;
// View for install progress
View mInstallConfirm;
// Buttons to indicate user acceptance
private Button mOk;
private Button mCancel;
static final String PREFS_ALLOWED_SOURCES = "allowed_sources";
// Dialog identifiers used in showDialog
private static final int DLG_BASE = 0;
private static final int DLG_REPLACE_APP = DLG_BASE + 1;
private static final int DLG_UNKNOWN_APPS = DLG_BASE + 2;
private static final int DLG_PACKAGE_ERROR = DLG_BASE + 3;
private static final int DLG_OUT_OF_SPACE = DLG_BASE + 4;
private static final int DLG_INSTALL_ERROR = DLG_BASE + 5;
private static final int DLG_ALLOW_SOURCE = DLG_BASE + 6;
private void startInstallConfirm() {
LinearLayout permsSection = (LinearLayout) mInstallConfirm.findViewById(R.id.permissions_section);
LinearLayout securityList = (LinearLayout) permsSection.findViewById(
R.id.security_settings_list);
boolean permVisible = false;
if(mPkgInfo != null) {
AppSecurityPermissions asp = new AppSecurityPermissions(this, mPkgInfo);
if(asp.getPermissionCount() > 0) {
permVisible = true;
securityList.addView(asp.getPermissionsView());
}
}
if(!permVisible){
permsSection.setVisibility(View.INVISIBLE);
}
mInstallConfirm.setVisibility(View.VISIBLE);
mOk = (Button)findViewById(R.id.ok_button);
mCancel = (Button)findViewById(R.id.cancel_button);
mOk.setOnClickListener(this);
mCancel.setOnClickListener(this);
}
private void showDialogInner(int id) {
// TODO better fix for this? Remove dialog so that it gets created again
removeDialog(id);
showDialog(id);
}
@Override
public Dialog onCreateDialog(int id, Bundle bundle) {
switch (id) {
case DLG_REPLACE_APP:
int msgId = R.string.dlg_app_replacement_statement;
// Customized text for system apps
if ((mAppInfo != null) && (mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
msgId = R.string.dlg_sys_app_replacement_statement;
}
return new AlertDialog.Builder(this)
.setTitle(R.string.dlg_app_replacement_title)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startInstallConfirm();
}})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.i(TAG, "Canceling installation");
setResult(RESULT_CANCELED);
finish();
}})
.setMessage(msgId)
.setOnCancelListener(this)
.create();
case DLG_UNKNOWN_APPS:
return new AlertDialog.Builder(this)
.setTitle(R.string.unknown_apps_dlg_title)
.setMessage(R.string.unknown_apps_dlg_text)
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.i(TAG, "Finishing off activity so that user can navigate to settings manually");
finish();
}})
.setPositiveButton(R.string.settings, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.i(TAG, "Launching settings");
launchSettingsAppAndFinish();
}
})
.setOnCancelListener(this)
.create();
case DLG_PACKAGE_ERROR :
return new AlertDialog.Builder(this)
.setTitle(R.string.Parse_error_dlg_title)
.setMessage(R.string.Parse_error_dlg_text)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.setOnCancelListener(this)
.create();
case DLG_OUT_OF_SPACE:
// Guaranteed not to be null. will default to package name if not set by app
CharSequence appTitle = mPm.getApplicationLabel(mPkgInfo.applicationInfo);
String dlgText = getString(R.string.out_of_space_dlg_text,
appTitle.toString());
return new AlertDialog.Builder(this)
.setTitle(R.string.out_of_space_dlg_title)
.setMessage(dlgText)
.setPositiveButton(R.string.manage_applications, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//launch manage applications
Intent intent = new Intent("android.intent
没有合适的资源?快使用搜索试试~ 我知道了~
小程序源码 PackageInstaller.rar
共257个文件
svn-base:97个
entries:71个
xml:70个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 27 浏览量
2023-03-19
20:26:32
上传
评论
收藏 500KB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序源码 PackageInstaller.rar (257个子文件)
PackageInstaller.apk 44KB
entries 1KB
entries 1KB
entries 1KB
entries 1KB
entries 762B
entries 621B
entries 620B
entries 620B
entries 450B
entries 447B
entries 447B
entries 447B
entries 447B
entries 447B
entries 444B
entries 444B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 443B
entries 314B
entries 297B
entries 289B
PackageInstallerActivity.java 17KB
PackageInstallerActivity.java 17KB
InstallAppProgress.java 12KB
InstallAppProgress.java 12KB
UninstallerActivity.java 8KB
PackageUtil.java 7KB
UninstallAppProgress.java 7KB
RemoveReceiver.java 1KB
CleanSpec.mk 2KB
Android.mk 227B
MODULE_LICENSE_APACHE2 0B
NOTICE 10KB
ic_fail.png 947B
ic_success.png 820B
ic_fail.png 707B
ic_success.png 651B
ic_fail.png 594B
ic_success.png 505B
PackageInstallerActivity.java.svn-base 16KB
InstallAppProgress.java.svn-base 11KB
NOTICE.svn-base 10KB
strings.xml.svn-base 10KB
strings.xml.svn-base 10KB
strings.xml.svn-base 9KB
strings.xml.svn-base 9KB
strings.xml.svn-base 9KB
strings.xml.svn-base 9KB
strings.xml.svn-base 9KB
共 257 条
- 1
- 2
- 3
资源评论
荣华富贵8
- 粉丝: 150
- 资源: 7649
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python 程序语言设计模式思路-创建型模式:原型模式:通过复制现有对象来创建新对象,面向对象编程
- 卸载软件geek卸载软件geek
- Python 程序语言设计模式思路-创建型模式:单例模式,确保一个类的唯一实例(装饰器)面向对象编程、继承
- skywalking-plugins.jar skywalking-alarm.jar
- 独栋别墅图纸D020-两层-10.00&11.00米- 施工图.dwg
- Python 程序语言设计模式思路-创建型模式:工厂模式,创建对象的统一接口,封装对象的创建逻辑
- python自学教程-05-json数据格式的介绍.ev4.rar
- python自学教程-04-自定义JavaScript.ev4.rar
- 《淘宝后台系统...》
- skywalking-plugins.jar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功