18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/aidl/android/content/pm/PackageStats.aidl:
--------------------------------------------------------------------------------
1 | /* //device/java/android/android/view/WindowManager.aidl
2 | **
3 | ** Copyright 2007, The Android Open Source Project
4 | **
5 | ** Licensed under the Apache License, Version 2.0 (the "License");
6 | ** you may not use this file except in compliance with the License.
7 | ** You may obtain a copy of the License at
8 | **
9 | ** http://www.apache.org/licenses/LICENSE-2.0
10 | **
11 | ** Unless required by applicable law or agreed to in writing, software
12 | ** distributed under the License is distributed on an "AS IS" BASIS,
13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | ** See the License for the specific language governing permissions and
15 | ** limitations under the License.
16 | */
17 |
18 | package android.content.pm;
19 |
20 | parcelable PackageStats;
21 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | signingConfigs {
5 | debug {
6 | keyAlias 'prafly'
7 | keyPassword 'prafly'
8 | storeFile file('E:/key/platform/new/prafly.keystore')
9 | storePassword 'prafly'
10 | }
11 | }
12 | compileSdkVersion 23
13 | buildToolsVersion "25.0.0"
14 | defaultConfig {
15 | applicationId "com.zhao.installapk"
16 | minSdkVersion 15
17 | targetSdkVersion 23
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | compile 'com.android.support:support-v4:23.0.0'
29 | compile 'com.android.support:design:23.0.0'
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/aidl/android/content/pm/IPackageInstallObserver.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | **
3 | ** Copyright 2007, The Android Open Source Project
4 | **
5 | ** Licensed under the Apache License, Version 2.0 (the "License");
6 | ** you may not use this file except in compliance with the License.
7 | ** You may obtain a copy of the License at
8 | **
9 | ** http://www.apache.org/licenses/LICENSE-2.0
10 | **
11 | ** Unless required by applicable law or agreed to in writing, software
12 | ** distributed under the License is distributed on an "AS IS" BASIS,
13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | ** See the License for the specific language governing permissions and
15 | ** limitations under the License.
16 | */
17 |
18 | package android.content.pm;
19 |
20 | /**
21 | * API for installation callbacks from the Package Manager.
22 | * @hide
23 | */
24 | oneway interface IPackageInstallObserver {
25 | void packageInstalled(in String packageName, int returnCode);
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/aidl/android/content/pm/IPackageMoveObserver.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | **
3 | ** Copyright 2007, The Android Open Source Project
4 | **
5 | ** Licensed under the Apache License, Version 2.0 (the "License");
6 | ** you may not use this file except in compliance with the License.
7 | ** You may obtain a copy of the License at
8 | **
9 | ** http://www.apache.org/licenses/LICENSE-2.0
10 | **
11 | ** Unless required by applicable law or agreed to in writing, software
12 | ** distributed under the License is distributed on an "AS IS" BASIS,
13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | ** See the License for the specific language governing permissions and
15 | ** limitations under the License.
16 | */
17 |
18 | package android.content.pm;
19 |
20 | /**
21 | * Callback for moving package resources from the Package Manager.
22 | * @hide
23 | */
24 | oneway interface IPackageMoveObserver {
25 | void packageMoved(in String packageName, int returnCode);
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/aidl/android/content/pm/IPackageDeleteObserver.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | **
3 | ** Copyright 2007, The Android Open Source Project
4 | **
5 | ** Licensed under the Apache License, Version 2.0 (the "License");
6 | ** you may not use this file except in compliance with the License.
7 | ** You may obtain a copy of the License at
8 | **
9 | ** http://www.apache.org/licenses/LICENSE-2.0
10 | **
11 | ** Unless required by applicable law or agreed to in writing, software
12 | ** distributed under the License is distributed on an "AS IS" BASIS,
13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | ** See the License for the specific language governing permissions and
15 | ** limitations under the License.
16 | */
17 |
18 | package android.content.pm;
19 |
20 | /**
21 | * API for deletion callbacks from the Package Manager.
22 | *
23 | * {@hide}
24 | */
25 | oneway interface IPackageDeleteObserver {
26 | void packageDeleted(in String packageName, in int returnCode);
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
18 |
19 |
20 |
21 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/aidl/android/content/pm/IPackageDataObserver.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | **
3 | ** Copyright 2007, The Android Open Source Project
4 | **
5 | ** Licensed under the Apache License, Version 2.0 (the "License");
6 | ** you may not use this file except in compliance with the License.
7 | ** You may obtain a copy of the License at
8 | **
9 | ** http://www.apache.org/licenses/LICENSE-2.0
10 | **
11 | ** Unless required by applicable law or agreed to in writing, software
12 | ** distributed under the License is distributed on an "AS IS" BASIS,
13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | ** See the License for the specific language governing permissions and
15 | ** limitations under the License.
16 | */
17 |
18 | package android.content.pm;
19 |
20 | /**
21 | * API for package data change related callbacks from the Package Manager.
22 | * Some usage scenarios include deletion of cache directory, generate
23 | * statistics related to code, data, cache usage(TODO)
24 | * {@hide}
25 | */
26 | oneway interface IPackageDataObserver {
27 | void onRemoveCompleted(in String packageName, boolean succeeded);
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/aidl/android/content/pm/IPackageStatsObserver.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | **
3 | ** Copyright 2007, The Android Open Source Project
4 | **
5 | ** Licensed under the Apache License, Version 2.0 (the "License");
6 | ** you may not use this file except in compliance with the License.
7 | ** You may obtain a copy of the License at
8 | **
9 | ** http://www.apache.org/licenses/LICENSE-2.0
10 | **
11 | ** Unless required by applicable law or agreed to in writing, software
12 | ** distributed under the License is distributed on an "AS IS" BASIS,
13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | ** See the License for the specific language governing permissions and
15 | ** limitations under the License.
16 | */
17 |
18 | package android.content.pm;
19 |
20 | import android.content.pm.PackageStats;
21 | /**
22 | * API for package data change related callbacks from the Package Manager.
23 | * Some usage scenarios include deletion of cache directory, generate
24 | * statistics related to code, data, cache usage(TODO)
25 | * {@hide}
26 | */
27 | oneway interface IPackageStatsObserver {
28 |
29 | void onGetStatsCompleted(in PackageStats pStats, boolean succeeded);
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhao/installapk/ApkManageReceiver.java:
--------------------------------------------------------------------------------
1 | package com.zhao.installapk;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 |
7 | public class ApkManageReceiver extends BroadcastReceiver {
8 | //开机广播
9 | public static final String BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
10 | //安装广播
11 | public static final String MANAGE_INSTALL_SILENT = "android.intent.action.zhao.MANAGE_INSTALL_SILENT";
12 |
13 | public static final String MANAGE_UN_INSTALL_SILENT = "android.intent.action.zhao.MANAGE_UNINSTALL_SILENT";
14 |
15 |
16 | public static final String START_SERVICE = "com.zhao.installapk.RUN";
17 |
18 | @Override
19 | public void onReceive(Context context, Intent intent) {
20 | if (intent.getAction().equals(BOOT_COMPLETED)) {
21 | Intent mintent = new Intent(context, ApkManageService.class);
22 | mintent.setAction(START_SERVICE);
23 | context.startService(mintent);
24 | } else if (intent.getAction().equals(MANAGE_INSTALL_SILENT)) {
25 | //判断所需字段是否完整
26 | if (!intent.hasExtra("package") || !intent.hasExtra("apkpath")) {
27 | return;
28 | }
29 | Intent mintent = new Intent(context, ApkManageService.class);
30 | mintent.setAction(ApkManageService.ACTION_INSTALL_SILENT);
31 | mintent.putExtra("package", intent.getStringExtra("package"));
32 | mintent.putExtra("apkpath", intent.getStringExtra("apkpath"));
33 | mintent.putExtra("isopen", intent.getBooleanExtra("isopen",false));
34 | context.startService(mintent);
35 | } else if (intent.getAction().equals(MANAGE_UN_INSTALL_SILENT)) {
36 | Intent mintent = new Intent(context, ApkManageService.class);
37 | mintent.setAction(ApkManageService.ACTION_UN_INSTALL_SILENT);
38 | mintent.putExtra("package", intent.getStringExtra("package"));
39 | context.startService(mintent);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SilentInstall
2 |
3 |
4 | ## 简介
5 |
6 | **静默安装**用于解决android自动嵌入式智能设备远程自动升级问题,安装过程无需人为操作。本项目通过获取系统platform签名,并利用隐藏Api--PackageManage实现Apk管理服务,设备内其他程序可通过广播接口完成应用程序静默安装与卸载功能。
7 |
8 |
9 | ## 折腾过程
10 |
11 | 最近为公司设备添加远程更新功能,在如何实现静默安装上折腾了很久,过程如下:
12 |
13 |
14 |
15 | * 首先android4.4以后应用拿到root权限非常比容易,被pass掉
16 |
17 | * 然后发现实现AccessibilityService可以帮助点击屏幕特定的按钮,本以为用ACTION_VIEW,ACTION_DELETE常规方法辅助监听对应的点击事件可以搞定,最后郁闷的发现虽然可以辅助点击,但前提是你有触动过屏幕才能帮你点击,意思是还是需要人,蛋疼了···
18 |
19 | * 最后还是用了网上比较流行的获取系统签名,使用PackageManage的方法,虽然过程还是挺麻烦,但还真的很好用,最后我把静默安装与卸载功能独立成一个开机启动的服务,发送指定广播可以调用,这样以后谁的应用想更新对接我接口就好,无需重新实现。
20 |
21 | 大家也可以直接拿来用,不过得用系统签名重新生成我的apk,缺点就是这样,不过已经免去了很多折腾,关于系统签名教程,[Click me](http://zhaopengcheng.top/2016/12/03/SystemSigned/)
22 |
23 | ## 效果
24 |
25 |
26 | ## 使用(Eclipse与android studio通用)
27 |
28 | 静默安装条件比较苛刻(只讨论无法root的情况),需使用与android系统相同的签名获取SignatureOrSystem权限,但由于android系统签名每个厂家Rom各有不同,故缺点也很明显改程序需专门制作匹配的签名。下面介绍如何使用该项目
29 |
30 | 1. 生成使用系统签名的本项目Apk(比较麻烦的一点)
31 | - 前提条件拿到系统的签名文件:platform.pk8 platform.x509.pem(可从码源获取,一般做嵌入式的公司应该不是问题)
32 | - 签名,如何制作签名, [请点击](https://my.oschina.net/blackylin/blog/176852)
33 |
34 | 2. 安装后开启自动启动服务,(PS:本想做一个纯Service程序,还得继续研究一下)
35 |
36 | 3. 在需要的地方,实现广播接口,OK
37 | - 需按照接口发送广播请求
38 |
39 | ``` java
40 |
41 | /**
42 | * 发送静默安装请求
43 | * @Action:android.intent.action.zhao.MANAGE_INSTALL_SILENT
44 | * @param apkPath 安装包本地地址
45 | * @param packageName 包名
46 | * @param isOpen 安装成功后是否打开
47 | */
48 | private void SendInstallBroadcast(String apkPath, String packageName, boolean isOpen){
49 | Intent mIntent = new Intent("android.intent.action.zhao.MANAGE_INSTALL_SILENT");
50 | mIntent.putExtra("apkpath",apkPath);
51 | mIntent.putExtra("package",packageName);
52 | mIntent.putExtra("isopen", isOpen);
53 | sendBroadcast(mIntent);
54 | }
55 |
56 | ```
57 |
58 | - 还可以实现接收结果广播,获得执行结果
59 |
60 | ``` java
61 |
62 | /**
63 | * 接收执行结果
64 | * 注册广播:com.zhao.install.EXCUTOR_RESULT
65 | */
66 | class myReceiver extends BroadcastReceiver{
67 | @Override
68 | public void onReceive(Context context, Intent intent) {
69 | //1表示执行成功
70 | int result = intent.getIntExtra("result",0);
71 | if(result == 1){
72 | showResult("操作成功");
73 | }else {
74 | showResult("操作失败");
75 | }
76 | }
77 | }
78 | ```
79 | - 示例代码见DemoActivity.java
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhao/installapk/ApkManageService.java:
--------------------------------------------------------------------------------
1 | package com.zhao.installapk;
2 |
3 | import android.app.Notification;
4 | import android.app.Service;
5 | import android.content.Intent;
6 | import android.os.IBinder;
7 | import android.support.v4.app.NotificationCompat;
8 | import android.util.Log;
9 |
10 | public class ApkManageService extends Service {
11 |
12 | public static final String TAG = ApkManageService.class.getName();
13 |
14 | public static final String ACTION_INSTALL_SILENT = "com.zhao.service.INSTALL_SILENCE";
15 |
16 | public static final String ACTION_UN_INSTALL_SILENT = "com.zhao.service.UN_INSTALL_SILENCE";
17 | //服务kill掉后,重启不保留intent
18 | private static final int returnValue = START_STICKY;
19 |
20 | /**
21 | * id不可设置为0,否则不能设置为前台service
22 | */
23 | private static final int NOTIFICATION_DOWNLOAD_PROGRESS_ID = 0x0001;
24 |
25 | @Override
26 | public void onCreate() {
27 | createForeground();
28 | super.onCreate();
29 | }
30 |
31 | public void createForeground() {
32 | //使用兼容版本
33 | NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
34 | //禁止用户点击删除按钮删除
35 | builder.setAutoCancel(false);
36 | //禁止滑动删除
37 | builder.setOngoing(true);
38 | //设置通知栏的标题内容
39 | builder.setContentTitle("zhao Install Service");
40 | //创建通知
41 | Notification notification = builder.build();
42 | //创建前台服务
43 | this.startForeground(NOTIFICATION_DOWNLOAD_PROGRESS_ID, notification);
44 | }
45 |
46 | @Override
47 | public int onStartCommand(Intent intent, int flags, int startId) {
48 | Log.d(TAG, "onStartCommand");
49 | if (intent == null) {
50 | return returnValue;
51 | }
52 | if (ACTION_INSTALL_SILENT.equals(intent.getAction())) {
53 | String filepath = intent.getStringExtra("apkpath");
54 | String pakcage = intent.getStringExtra("package");
55 | boolean isopen = intent.getBooleanExtra("isopen", false);
56 | ApkOperateManager.installApkDefaul(this, filepath, pakcage, isopen);
57 | } else if (ACTION_UN_INSTALL_SILENT.equals(intent.getAction())) {
58 | String pakcage = intent.getStringExtra("package");
59 | ApkOperateManager.uninstallApkDefaul(this, pakcage);
60 | }
61 | return returnValue;
62 | }
63 |
64 | @Override
65 | public IBinder onBind(Intent intent) {
66 | // TODO Auto-generated method stub
67 | return null;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/import-summary.txt:
--------------------------------------------------------------------------------
1 | ECLIPSE ANDROID PROJECT IMPORT SUMMARY
2 | ======================================
3 |
4 | Ignored Files:
5 | --------------
6 | The following files were *not* copied into the new Gradle project; you
7 | should evaluate whether these are still needed in your project and if
8 | so manually move them:
9 |
10 | * ic_launcher-web.png
11 | * proguard-project.txt
12 |
13 | Replaced Jars with Dependencies:
14 | --------------------------------
15 | The importer recognized the following .jar files as third party
16 | libraries and replaced them with Gradle dependencies instead. This has
17 | the advantage that more explicit version information is known, and the
18 | libraries can be updated automatically. However, it is possible that
19 | the .jar file in your project was of an older version than the
20 | dependency we picked, which could render the project not compileable.
21 | You can disable the jar replacement in the import wizard and try again:
22 |
23 | android-support-v4.jar => com.android.support:support-v4:22.2.1
24 |
25 | Moved Files:
26 | ------------
27 | Android Gradle projects use a different directory structure than ADT
28 | Eclipse projects. Here's how the projects were restructured:
29 |
30 | * AndroidManifest.xml => app\src\main\AndroidManifest.xml
31 | * assets\ => app\src\main\assets
32 | * res\ => app\src\main\res\
33 | * src\ => app\src\main\java\
34 | * src\android\content\pm\IPackageDataObserver.aidl => app\src\main\aidl\android\content\pm\IPackageDataObserver.aidl
35 | * src\android\content\pm\IPackageDeleteObserver.aidl => app\src\main\aidl\android\content\pm\IPackageDeleteObserver.aidl
36 | * src\android\content\pm\IPackageInstallObserver.aidl => app\src\main\aidl\android\content\pm\IPackageInstallObserver.aidl
37 | * src\android\content\pm\IPackageMoveObserver.aidl => app\src\main\aidl\android\content\pm\IPackageMoveObserver.aidl
38 | * src\android\content\pm\IPackageStatsObserver.aidl => app\src\main\aidl\android\content\pm\IPackageStatsObserver.aidl
39 | * src\android\content\pm\PackageStats.aidl => app\src\main\aidl\android\content\pm\PackageStats.aidl
40 |
41 | Next Steps:
42 | -----------
43 | You can now build the project. The Gradle project needs network
44 | connectivity to download dependencies.
45 |
46 | Bugs:
47 | -----
48 | If for some reason your project does not build, and you determine that
49 | it is due to a bug or limitation of the Eclipse to Gradle importer,
50 | please file a bug at http://b.android.com with category
51 | Component-Tools.
52 |
53 | (This import summary is for your information only, and can be deleted
54 | after import once you are satisfied with the results.)
55 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhao/installapk/DemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.zhao.installapk;
2 |
3 | import java.io.File;
4 | import java.util.HashMap;
5 |
6 | import android.app.Activity;
7 | import android.content.BroadcastReceiver;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.content.IntentFilter;
11 | import android.os.Bundle;
12 | import android.os.Environment;
13 | import android.os.Handler;
14 | import android.os.Message;
15 | import android.support.design.widget.Snackbar;
16 | import android.view.View;
17 | import android.widget.EditText;
18 | import android.widget.Toast;
19 |
20 | /**
21 | * @author zhao
22 | * 测试Activity
23 | */
24 | public class DemoActivity extends Activity {
25 |
26 | private String filepath = Environment.getExternalStorageDirectory() + File.separator + "Download" + File.separator;
27 |
28 | private String filename = "AidDeviceTest.apk";
29 |
30 | private String packagename = "com.zhao.aiddevicetest";
31 |
32 | private boolean isOpen = true;
33 |
34 | private static final String RESULT_BROAD = "com.zhao.install.EXCUTOR_RESULT";
35 |
36 | View view;
37 |
38 | private myReceiver receiver;
39 |
40 | /**
41 | * 接收执行结果
42 | * 注册广播:com.zhao.install.EXCUTOR_RESULT
43 | */
44 | class myReceiver extends BroadcastReceiver{
45 | @Override
46 | public void onReceive(Context context, Intent intent) {
47 | //1表示执行成功
48 | int result = intent.getIntExtra("result",0);
49 | if(result == 1){
50 | showResult("操作成功");
51 | }else {
52 | showResult("操作失败:" + result);
53 | }
54 | }
55 | }
56 |
57 | @Override
58 | protected void onResume() {
59 | IntentFilter intentFilter = new IntentFilter(RESULT_BROAD);
60 | receiver = new myReceiver();
61 | registerReceiver(receiver, intentFilter);
62 | super.onResume();
63 | }
64 |
65 | @Override
66 | protected void onPause() {
67 | unregisterReceiver(receiver);
68 | super.onPause();
69 | }
70 |
71 | @Override
72 | protected void onCreate(Bundle savedInstanceState) {
73 | super.onCreate(savedInstanceState);
74 | setContentView(R.layout.activity_main);
75 | view = findViewById(R.id.btn_install);
76 | }
77 |
78 | public void installOnClick(View view) {
79 | SendInstallBroadcast(filepath + filename, packagename, isOpen);
80 | }
81 |
82 | public void unInstallOnclick(View view) {
83 | SendUnInstallBroadcast(packagename);
84 | }
85 |
86 | public void showResult(String str){
87 | Toast.makeText(this, str ,Toast.LENGTH_SHORT).show();
88 | }
89 | /**
90 | * 发送静默安装请求
91 | * @Action:android.intent.action.zhao.MANAGE_INSTALL_SILENT
92 | * @param apkPath 安装包本地地址
93 | * @param packageName 包名
94 | * @param isOpen 安装成功后是否打开
95 | */
96 | private void SendInstallBroadcast(String apkPath, String packageName, boolean isOpen){
97 | Intent mIntent = new Intent("android.intent.action.zhao.MANAGE_INSTALL_SILENT");
98 | mIntent.putExtra("apkpath",apkPath);
99 | mIntent.putExtra("package",packageName);
100 | mIntent.putExtra("isopen", isOpen);
101 | sendBroadcast(mIntent);
102 | }
103 |
104 | /**
105 | * 发送静默卸载请求
106 | * @Action:android.intent.action.zhao.MANAGE_UNINSTALL_SILENT
107 | * @param packageName 卸载apk包名
108 | */
109 | private void SendUnInstallBroadcast(String packageName){
110 | Intent mIntent = new Intent("android.intent.action.zhao.MANAGE_UNINSTALL_SILENT");
111 | mIntent.putExtra("package",packageName);
112 | sendBroadcast(mIntent);
113 | }
114 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/zhao/installapk/ApkOperateManager.java:
--------------------------------------------------------------------------------
1 | package com.zhao.installapk;
2 |
3 | import java.io.File;
4 |
5 | import android.app.AlarmManager;
6 | import android.app.PendingIntent;
7 | import android.app.Service;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.content.pm.IPackageDeleteObserver;
11 | import android.content.pm.IPackageInstallObserver;
12 | import android.content.pm.PackageManager;
13 | import android.net.Uri;
14 | import android.os.RemoteException;
15 | import android.util.Log;
16 |
17 |
18 | public class ApkOperateManager {
19 | public static String TAG = "ApkOperateManager";
20 | public static final String EXCUTOR_RESULT = "com.zhao.install.EXCUTOR_RESULT";
21 |
22 | //安装apk
23 | public static void installApk(Context context, String fileName) {
24 | Intent intent = new Intent();
25 | intent.setAction(Intent.ACTION_VIEW);
26 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
27 | intent.setDataAndType(Uri.parse("file://" + fileName),
28 | "application/vnd.android.package-archive");
29 | context.startActivity(intent);
30 | }
31 |
32 | //卸载apk
33 | public static void uninstallApk(Context context, String packageName) {
34 | Uri uri = Uri.parse("package:" + packageName);
35 | Intent intent = new Intent(Intent.ACTION_DELETE, uri);
36 | context.startActivity(intent);
37 | }
38 |
39 | //静默安装
40 | public static void installApkDefaul(Context context, String fileName, String pakcageName, boolean isopen) {
41 | Log.d(TAG, "jing mo an zhuang");
42 | File file = new File(fileName);
43 | int installFlags = 0;
44 | if (!file.exists())
45 | return;
46 | Log.d(TAG, "jing mo an zhuang out");
47 | installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
48 | PackageManager pm = context.getPackageManager();
49 | IPackageInstallObserver observer = new MyPakcageInstallObserver(context, pakcageName, isopen);
50 | pm.installPackage(Uri.fromFile(file), observer, installFlags, pakcageName);
51 | }
52 |
53 | //静默卸载
54 | public static void uninstallApkDefaul(Context context, String packageName) {
55 | PackageManager pm = context.getPackageManager();
56 | IPackageDeleteObserver observer = new MyPackageDeleteObserver(context);
57 | pm.deletePackage(packageName, observer, 0);
58 | }
59 |
60 | //2秒后回馈结果
61 | private static void sendResultCode(Context context, int returnCode,
62 | String packageName) {
63 | Intent mResultIntent = new Intent(EXCUTOR_RESULT);
64 | mResultIntent.putExtra("result", returnCode);
65 | mResultIntent.putExtra("package", packageName);
66 | AlarmManager alarmManager = (AlarmManager) context
67 | .getSystemService(Service.ALARM_SERVICE);
68 | PendingIntent pendingIntentExprie = PendingIntent.getBroadcast(context,
69 | 0, mResultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
70 | alarmManager.set(AlarmManager.RTC,
71 | System.currentTimeMillis() + 2 * 1000, pendingIntentExprie);
72 | }
73 |
74 |
75 | //静默安装回调
76 | private static class MyPakcageInstallObserver extends IPackageInstallObserver.Stub {
77 | private static final PackageManager Intent = null;
78 | Context context;
79 | String packageName;
80 | boolean isOpen;
81 |
82 | MyPakcageInstallObserver(Context conext, String packageName, boolean isopen) {
83 | this.context = conext;
84 | this.packageName = packageName;
85 | this.isOpen = isopen;
86 | }
87 |
88 | @Override
89 | public void packageInstalled(String packageName, int returnCode)
90 | throws RemoteException {
91 | Log.i(TAG, "returnCode = " + returnCode);//返回1代表安装成功
92 | sendResultCode(context,returnCode, packageName);
93 | if (isOpen) {
94 | // 启动目标应用
95 | PackageManager packManager = context.getPackageManager();
96 | // 这里的packageName就是从上面得到的目标apk的包名
97 | Intent resolveIntent = packManager.getLaunchIntentForPackage(packageName);
98 | context.startActivity(resolveIntent);
99 | }
100 | }
101 | }
102 |
103 | //静默卸载回调
104 | private static class MyPackageDeleteObserver extends IPackageDeleteObserver.Stub {
105 | Context context;
106 | MyPackageDeleteObserver(Context context){
107 | this.context = context;
108 | }
109 | @Override
110 | public void packageDeleted(String packageName, int returnCode) {
111 | Log.d(TAG, "returnCode = " + returnCode);//返回1代表卸载成功
112 | sendResultCode(context,returnCode, packageName);
113 | }
114 |
115 | }
116 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/android/content/pm/PackageManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package android.content.pm;
18 |
19 | import java.util.List;
20 |
21 | import android.content.ComponentName;
22 | import android.content.Context;
23 | import android.content.Intent;
24 | import android.content.IntentFilter;
25 | import android.content.IntentSender;
26 | import android.content.res.Resources;
27 | import android.content.res.XmlResourceParser;
28 | import android.graphics.drawable.Drawable;
29 | import android.net.Uri;
30 | import android.util.AndroidException;
31 |
32 | /**
33 | * Class for retrieving various kinds of information related to the application
34 | * packages that are currently installed on the device.
35 | *
36 | * You can find this class through {@link Context#getPackageManager}.
37 | */
38 | public abstract class PackageManager {
39 |
40 | /**
41 | * This exception is thrown when a given package, application, or component
42 | * name can not be found.
43 | */
44 | public static class NameNotFoundException extends AndroidException {
45 | public NameNotFoundException() {
46 | }
47 |
48 | public NameNotFoundException(String name) {
49 | super(name);
50 | }
51 | }
52 |
53 | /**
54 | * {@link PackageInfo} flag: return information about activities in the
55 | * package in {@link PackageInfo#activities}.
56 | */
57 | public static final int GET_ACTIVITIES = 0x00000001;
58 |
59 | /**
60 | * {@link PackageInfo} flag: return information about intent receivers in
61 | * the package in {@link PackageInfo#receivers}.
62 | */
63 | public static final int GET_RECEIVERS = 0x00000002;
64 |
65 | /**
66 | * {@link PackageInfo} flag: return information about services in the
67 | * package in {@link PackageInfo#services}.
68 | */
69 | public static final int GET_SERVICES = 0x00000004;
70 |
71 | /**
72 | * {@link PackageInfo} flag: return information about content providers in
73 | * the package in {@link PackageInfo#providers}.
74 | */
75 | public static final int GET_PROVIDERS = 0x00000008;
76 |
77 | /**
78 | * {@link PackageInfo} flag: return information about instrumentation in the
79 | * package in {@link PackageInfo#instrumentation}.
80 | */
81 | public static final int GET_INSTRUMENTATION = 0x00000010;
82 |
83 | /**
84 | * {@link PackageInfo} flag: return information about the intent filters
85 | * supported by the activity.
86 | */
87 | public static final int GET_INTENT_FILTERS = 0x00000020;
88 |
89 | /**
90 | * {@link PackageInfo} flag: return information about the signatures
91 | * included in the package.
92 | */
93 | public static final int GET_SIGNATURES = 0x00000040;
94 |
95 | /**
96 | * {@link ResolveInfo} flag: return the IntentFilter that was matched for a
97 | * particular ResolveInfo in {@link ResolveInfo#filter}.
98 | */
99 | public static final int GET_RESOLVED_FILTER = 0x00000040;
100 |
101 | /**
102 | * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
103 | * data {@link android.os.Bundle}s that are associated with a component.
104 | * This applies for any API returning a ComponentInfo subclass.
105 | */
106 | public static final int GET_META_DATA = 0x00000080;
107 |
108 | /**
109 | * {@link PackageInfo} flag: return the {@link PackageInfo#gids group ids}
110 | * that are associated with an application. This applies for any API
111 | * returning an PackageInfo class, either directly or nested inside of
112 | * another.
113 | */
114 | public static final int GET_GIDS = 0x00000100;
115 |
116 | /**
117 | * {@link PackageInfo} flag: include disabled components in the returned
118 | * info.
119 | */
120 | public static final int GET_DISABLED_COMPONENTS = 0x00000200;
121 |
122 | /**
123 | * {@link ApplicationInfo} flag: return the
124 | * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
125 | * that are associated with an application. This applies for any API
126 | * returning an ApplicationInfo class, either directly or nested inside of
127 | * another.
128 | */
129 | public static final int GET_SHARED_LIBRARY_FILES = 0x00000400;
130 |
131 | /**
132 | * {@link ProviderInfo} flag: return the
133 | * {@link ProviderInfo#uriPermissionPatterns URI permission patterns} that
134 | * are associated with a content provider. This applies for any API
135 | * returning an ProviderInfo class, either directly or nested inside of
136 | * another.
137 | */
138 | public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800;
139 | /**
140 | * {@link PackageInfo} flag: return information about permissions in the
141 | * package in {@link PackageInfo#permissions}.
142 | */
143 | public static final int GET_PERMISSIONS = 0x00001000;
144 |
145 | /**
146 | * Flag parameter to retrieve some information about all applications (even
147 | * uninstalled ones) which have data directories. This state could have
148 | * resulted if applications have been deleted with flag
149 | * {@code DONT_DELETE_DATA} with a possibility of being replaced or
150 | * reinstalled in future.
151 | *
152 | * Note: this flag may cause less information about currently installed
153 | * applications to be returned.
154 | */
155 | public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
156 |
157 | /**
158 | * {@link PackageInfo} flag: return information about hardware preferences
159 | * in {@link PackageInfo#configPreferences PackageInfo.configPreferences}
160 | * and requested features in {@link PackageInfo#reqFeatures
161 | * PackageInfo.reqFeatures}.
162 | */
163 | public static final int GET_CONFIGURATIONS = 0x00004000;
164 |
165 | /**
166 | * Resolution and querying flag: if set, only filters that support the
167 | * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
168 | * matching. This is a synonym for including the CATEGORY_DEFAULT in your
169 | * supplied Intent.
170 | */
171 | public static final int MATCH_DEFAULT_ONLY = 0x00010000;
172 |
173 | /**
174 | * Permission check result: this is returned by {@link #checkPermission} if
175 | * the permission has been granted to the given package.
176 | */
177 | public static final int PERMISSION_GRANTED = 0;
178 |
179 | /**
180 | * Permission check result: this is returned by {@link #checkPermission} if
181 | * the permission has not been granted to the given package.
182 | */
183 | public static final int PERMISSION_DENIED = -1;
184 |
185 | /**
186 | * Signature check result: this is returned by {@link #checkSignatures} if
187 | * all signatures on the two packages match.
188 | */
189 | public static final int SIGNATURE_MATCH = 0;
190 |
191 | /**
192 | * Signature check result: this is returned by {@link #checkSignatures} if
193 | * neither of the two packages is signed.
194 | */
195 | public static final int SIGNATURE_NEITHER_SIGNED = 1;
196 |
197 | /**
198 | * Signature check result: this is returned by {@link #checkSignatures} if
199 | * the first package is not signed but the second is.
200 | */
201 | public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
202 |
203 | /**
204 | * Signature check result: this is returned by {@link #checkSignatures} if
205 | * the second package is not signed but the first is.
206 | */
207 | public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
208 |
209 | /**
210 | * Signature check result: this is returned by {@link #checkSignatures} if
211 | * not all signatures on both packages match.
212 | */
213 | public static final int SIGNATURE_NO_MATCH = -3;
214 |
215 | /**
216 | * Signature check result: this is returned by {@link #checkSignatures} if
217 | * either of the packages are not valid.
218 | */
219 | public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
220 |
221 | /**
222 | * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and
223 | * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
224 | * component or application is in its default enabled state (as specified in
225 | * its manifest).
226 | */
227 | public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
228 |
229 | /**
230 | * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and
231 | * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
232 | * component or application has been explictily enabled, regardless of what
233 | * it has specified in its manifest.
234 | */
235 | public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
236 |
237 | /**
238 | * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and
239 | * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
240 | * component or application has been explicitly disabled, regardless of what
241 | * it has specified in its manifest.
242 | */
243 | public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
244 |
245 | /**
246 | * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only:
247 | * The user has explicitly disabled the application, regardless of what it
248 | * has specified in its manifest. Because this is due to the user's request,
249 | * they may re-enable it if desired through the appropriate system UI. This
250 | * option currently can not be used with
251 | * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
252 | */
253 | public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
254 |
255 | /**
256 | * Flag parameter for
257 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
258 | * indicate that this package should be installed as forward locked, i.e.
259 | * only the app itself should have access to its code and non-resource
260 | * assets.
261 | *
262 | * @hide
263 | */
264 | public static final int INSTALL_FORWARD_LOCK = 0x00000001;
265 |
266 | /**
267 | * Flag parameter for {@link #installPackage} to indicate that you want to
268 | * replace an already installed package, if one exists.
269 | *
270 | * @hide
271 | */
272 | public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
273 |
274 | /**
275 | * Flag parameter for {@link #installPackage} to indicate that you want to
276 | * allow test packages (those that have set android:testOnly in their
277 | * manifest) to be installed.
278 | *
279 | * @hide
280 | */
281 | public static final int INSTALL_ALLOW_TEST = 0x00000004;
282 |
283 | /**
284 | * Flag parameter for {@link #installPackage} to indicate that this package
285 | * has to be installed on the sdcard.
286 | *
287 | * @hide
288 | */
289 | public static final int INSTALL_EXTERNAL = 0x00000008;
290 |
291 | /**
292 | * Flag parameter for {@link #installPackage} to indicate that this package
293 | * has to be installed on the sdcard.
294 | *
295 | * @hide
296 | */
297 | public static final int INSTALL_INTERNAL = 0x00000010;
298 |
299 | /**
300 | * Flag parameter for {@link #installPackage} to indicate that this install
301 | * was initiated via ADB.
302 | *
303 | * @hide
304 | */
305 | public static final int INSTALL_FROM_ADB = 0x00000020;
306 |
307 | /**
308 | * Flag parameter for
309 | * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)}
310 | * to indicate that you don't want to kill the app containing the component.
311 | * Be careful when you set this since changing component states can make the
312 | * containing application's behavior unpredictable.
313 | */
314 | public static final int DONT_KILL_APP = 0x00000001;
315 |
316 | /**
317 | * Installation return code: this is passed to the
318 | * {@link IPackageInstallObserver} by
319 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on
320 | * success.
321 | *
322 | * @hide
323 | */
324 | public static final int INSTALL_SUCCEEDED = 1;
325 |
326 | /**
327 | * Installation return code: this is passed to the
328 | * {@link IPackageInstallObserver} by
329 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
330 | * the package is already installed.
331 | *
332 | * @hide
333 | */
334 | public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
335 |
336 | /**
337 | * Installation return code: this is passed to the
338 | * {@link IPackageInstallObserver} by
339 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
340 | * the package archive file is invalid.
341 | *
342 | * @hide
343 | */
344 | public static final int INSTALL_FAILED_INVALID_APK = -2;
345 |
346 | /**
347 | * Installation return code: this is passed to the
348 | * {@link IPackageInstallObserver} by
349 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
350 | * the URI passed in is invalid.
351 | *
352 | * @hide
353 | */
354 | public static final int INSTALL_FAILED_INVALID_URI = -3;
355 |
356 | /**
357 | * Installation return code: this is passed to the
358 | * {@link IPackageInstallObserver} by
359 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
360 | * the package manager service found that the device didn't have enough
361 | * storage space to install the app.
362 | *
363 | * @hide
364 | */
365 | public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
366 |
367 | /**
368 | * Installation return code: this is passed to the
369 | * {@link IPackageInstallObserver} by
370 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
371 | * a package is already installed with the same name.
372 | *
373 | * @hide
374 | */
375 | public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
376 |
377 | /**
378 | * Installation return code: this is passed to the
379 | * {@link IPackageInstallObserver} by
380 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
381 | * the requested shared user does not exist.
382 | *
383 | * @hide
384 | */
385 | public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
386 |
387 | /**
388 | * Installation return code: this is passed to the
389 | * {@link IPackageInstallObserver} by
390 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
391 | * a previously installed package of the same name has a different signature
392 | * than the new package (and the old package's data was not removed).
393 | *
394 | * @hide
395 | */
396 | public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
397 |
398 | /**
399 | * Installation return code: this is passed to the
400 | * {@link IPackageInstallObserver} by
401 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
402 | * the new package is requested a shared user which is already installed on
403 | * the device and does not have matching signature.
404 | *
405 | * @hide
406 | */
407 | public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
408 |
409 | /**
410 | * Installation return code: this is passed to the
411 | * {@link IPackageInstallObserver} by
412 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
413 | * the new package uses a shared library that is not available.
414 | *
415 | * @hide
416 | */
417 | public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
418 |
419 | /**
420 | * Installation return code: this is passed to the
421 | * {@link IPackageInstallObserver} by
422 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
423 | * the new package uses a shared library that is not available.
424 | *
425 | * @hide
426 | */
427 | public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
428 |
429 | /**
430 | * Installation return code: this is passed to the
431 | * {@link IPackageInstallObserver} by
432 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
433 | * the new package failed while optimizing and validating its dex files,
434 | * either because there was not enough storage or the validation failed.
435 | *
436 | * @hide
437 | */
438 | public static final int INSTALL_FAILED_DEXOPT = -11;
439 |
440 | /**
441 | * Installation return code: this is passed to the
442 | * {@link IPackageInstallObserver} by
443 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
444 | * the new package failed because the current SDK version is older than that
445 | * required by the package.
446 | *
447 | * @hide
448 | */
449 | public static final int INSTALL_FAILED_OLDER_SDK = -12;
450 |
451 | /**
452 | * Installation return code: this is passed to the
453 | * {@link IPackageInstallObserver} by
454 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
455 | * the new package failed because it contains a content provider with the
456 | * same authority as a provider already installed in the system.
457 | *
458 | * @hide
459 | */
460 | public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
461 |
462 | /**
463 | * Installation return code: this is passed to the
464 | * {@link IPackageInstallObserver} by
465 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
466 | * the new package failed because the current SDK version is newer than that
467 | * required by the package.
468 | *
469 | * @hide
470 | */
471 | public static final int INSTALL_FAILED_NEWER_SDK = -14;
472 |
473 | /**
474 | * Installation return code: this is passed to the
475 | * {@link IPackageInstallObserver} by
476 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
477 | * the new package failed because it has specified that it is a test-only
478 | * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
479 | * flag.
480 | *
481 | * @hide
482 | */
483 | public static final int INSTALL_FAILED_TEST_ONLY = -15;
484 |
485 | /**
486 | * Installation return code: this is passed to the
487 | * {@link IPackageInstallObserver} by
488 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
489 | * the package being installed contains native code, but none that is
490 | * compatible with the the device's CPU_ABI.
491 | *
492 | * @hide
493 | */
494 | public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
495 |
496 | /**
497 | * Installation return code: this is passed to the
498 | * {@link IPackageInstallObserver} by
499 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
500 | * the new package uses a feature that is not available.
501 | *
502 | * @hide
503 | */
504 | public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
505 |
506 | // ------ Errors related to sdcard
507 | /**
508 | * Installation return code: this is passed to the
509 | * {@link IPackageInstallObserver} by
510 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
511 | * a secure container mount point couldn't be accessed on external media.
512 | *
513 | * @hide
514 | */
515 | public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
516 |
517 | /**
518 | * Installation return code: this is passed to the
519 | * {@link IPackageInstallObserver} by
520 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
521 | * the new package couldn't be installed in the specified install location.
522 | *
523 | * @hide
524 | */
525 | public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
526 |
527 | /**
528 | * Installation return code: this is passed to the
529 | * {@link IPackageInstallObserver} by
530 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
531 | * the new package couldn't be installed in the specified install location
532 | * because the media is not available.
533 | *
534 | * @hide
535 | */
536 | public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
537 |
538 | /**
539 | * Installation return code: this is passed to the
540 | * {@link IPackageInstallObserver} by
541 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
542 | * the new package couldn't be installed because the verification timed out.
543 | *
544 | * @hide
545 | */
546 | public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
547 |
548 | /**
549 | * Installation return code: this is passed to the
550 | * {@link IPackageInstallObserver} by
551 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
552 | * the new package couldn't be installed because the verification did not
553 | * succeed.
554 | *
555 | * @hide
556 | */
557 | public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
558 |
559 | /**
560 | * Installation return code: this is passed to the
561 | * {@link IPackageInstallObserver} by
562 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
563 | * the package changed from what the calling program expected.
564 | *
565 | * @hide
566 | */
567 | public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
568 |
569 | /**
570 | * Installation parse return code: this is passed to the
571 | * {@link IPackageInstallObserver} by
572 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
573 | * the parser was given a path that is not a file, or does not end with the
574 | * expected '.apk' extension.
575 | *
576 | * @hide
577 | */
578 | public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
579 |
580 | /**
581 | * Installation parse return code: this is passed to the
582 | * {@link IPackageInstallObserver} by
583 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
584 | * the parser was unable to retrieve the AndroidManifest.xml file.
585 | *
586 | * @hide
587 | */
588 | public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
589 |
590 | /**
591 | * Installation parse return code: this is passed to the
592 | * {@link IPackageInstallObserver} by
593 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
594 | * the parser encountered an unexpected exception.
595 | *
596 | * @hide
597 | */
598 | public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
599 |
600 | /**
601 | * Installation parse return code: this is passed to the
602 | * {@link IPackageInstallObserver} by
603 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
604 | * the parser did not find any certificates in the .apk.
605 | *
606 | * @hide
607 | */
608 | public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
609 |
610 | /**
611 | * Installation parse return code: this is passed to the
612 | * {@link IPackageInstallObserver} by
613 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
614 | * the parser found inconsistent certificates on the files in the .apk.
615 | *
616 | * @hide
617 | */
618 | public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
619 |
620 | /**
621 | * Installation parse return code: this is passed to the
622 | * {@link IPackageInstallObserver} by
623 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
624 | * the parser encountered a CertificateEncodingException in one of the files
625 | * in the .apk.
626 | *
627 | * @hide
628 | */
629 | public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
630 |
631 | /**
632 | * Installation parse return code: this is passed to the
633 | * {@link IPackageInstallObserver} by
634 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
635 | * the parser encountered a bad or missing package name in the manifest.
636 | *
637 | * @hide
638 | */
639 | public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
640 |
641 | /**
642 | * Installation parse return code: this is passed to the
643 | * {@link IPackageInstallObserver} by
644 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
645 | * the parser encountered a bad shared user id name in the manifest.
646 | *
647 | * @hide
648 | */
649 | public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
650 |
651 | /**
652 | * Installation parse return code: this is passed to the
653 | * {@link IPackageInstallObserver} by
654 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
655 | * the parser encountered some structural problem in the manifest.
656 | *
657 | * @hide
658 | */
659 | public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
660 |
661 | /**
662 | * Installation parse return code: this is passed to the
663 | * {@link IPackageInstallObserver} by
664 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
665 | * the parser did not find any actionable tags (instrumentation or
666 | * application) in the manifest.
667 | *
668 | * @hide
669 | */
670 | public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
671 |
672 | /**
673 | * Installation failed return code: this is passed to the
674 | * {@link IPackageInstallObserver} by
675 | * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
676 | * the system failed to install the package because of system issues.
677 | *
678 | * @hide
679 | */
680 | public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
681 |
682 | /**
683 | * Flag parameter for {@link #deletePackage} to indicate that you don't want
684 | * to delete the package's data directory.
685 | *
686 | * @hide
687 | */
688 | public static final int DONT_DELETE_DATA = 0x00000001;
689 |
690 | /**
691 | * Return code for when package deletion succeeds. This is passed to the
692 | * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
693 | * succeeded in deleting the package.
694 | *
695 | * @hide
696 | */
697 | public static final int DELETE_SUCCEEDED = 1;
698 |
699 | /**
700 | * Deletion failed return code: this is passed to the
701 | * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
702 | * failed to delete the package for an unspecified reason.
703 | *
704 | * @hide
705 | */
706 | public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
707 |
708 | /**
709 | * Deletion failed return code: this is passed to the
710 | * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
711 | * failed to delete the package because it is the active DevicePolicy
712 | * manager.
713 | *
714 | * @hide
715 | */
716 | public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
717 |
718 | /**
719 | * Return code that is passed to the {@link IPackageMoveObserver} by
720 | * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
721 | * package has been successfully moved by the system.
722 | *
723 | * @hide
724 | */
725 | public static final int MOVE_SUCCEEDED = 1;
726 | /**
727 | * Error code that is passed to the {@link IPackageMoveObserver} by
728 | * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
729 | * package hasn't been successfully moved by the system because of
730 | * insufficient memory on specified media.
731 | *
732 | * @hide
733 | */
734 | public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
735 |
736 | /**
737 | * Error code that is passed to the {@link IPackageMoveObserver} by
738 | * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
739 | * specified package doesn't exist.
740 | *
741 | * @hide
742 | */
743 | public static final int MOVE_FAILED_DOESNT_EXIST = -2;
744 |
745 | /**
746 | * Error code that is passed to the {@link IPackageMoveObserver} by
747 | * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
748 | * specified package cannot be moved since its a system package.
749 | *
750 | * @hide
751 | */
752 | public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
753 |
754 | /**
755 | * Error code that is passed to the {@link IPackageMoveObserver} by
756 | * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
757 | * specified package cannot be moved since its forward locked.
758 | *
759 | * @hide
760 | */
761 | public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
762 |
763 | /**
764 | * Error code that is passed to the {@link IPackageMoveObserver} by
765 | * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
766 | * specified package cannot be moved to the specified location.
767 | *
768 | * @hide
769 | */
770 | public static final int MOVE_FAILED_INVALID_LOCATION = -5;
771 |
772 | /**
773 | * Error code that is passed to the {@link IPackageMoveObserver} by
774 | * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
775 | * specified package cannot be moved to the specified location.
776 | *
777 | * @hide
778 | */
779 | public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
780 |
781 | /**
782 | * Error code that is passed to the {@link IPackageMoveObserver} by
783 | * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
784 | * specified package already has an operation pending in the
785 | * {@link PackageHandler} queue.
786 | *
787 | * @hide
788 | */
789 | public static final int MOVE_FAILED_OPERATION_PENDING = -7;
790 |
791 | /**
792 | * Flag parameter for {@link #movePackage} to indicate that the package
793 | * should be moved to internal storage if its been installed on external
794 | * media.
795 | *
796 | * @hide
797 | */
798 | public static final int MOVE_INTERNAL = 0x00000001;
799 |
800 | /**
801 | * Flag parameter for {@link #movePackage} to indicate that the package
802 | * should be moved to external media.
803 | *
804 | * @hide
805 | */
806 | public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
807 |
808 | /**
809 | * Usable by the required verifier as the {@code verificationCode} argument
810 | * for {@link PackageManager#verifyPendingInstall} to indicate that it will
811 | * allow the installation to proceed without any of the optional verifiers
812 | * needing to vote.
813 | *
814 | * @hide
815 | */
816 | public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
817 |
818 | /**
819 | * Used as the {@code verificationCode} argument for
820 | * {@link PackageManager#verifyPendingInstall} to indicate that the calling
821 | * package verifier allows the installation to proceed.
822 | */
823 | public static final int VERIFICATION_ALLOW = 1;
824 |
825 | /**
826 | * Used as the {@code verificationCode} argument for
827 | * {@link PackageManager#verifyPendingInstall} to indicate the calling
828 | * package verifier does not vote to allow the installation to proceed.
829 | */
830 | public static final int VERIFICATION_REJECT = -1;
831 |
832 | /**
833 | * Range of IDs allocated for a user.
834 | *
835 | * @hide
836 | */
837 | public static final int PER_USER_RANGE = 100000;
838 |
839 | /**
840 | * Feature for {@link #getSystemAvailableFeatures} and
841 | * {@link #hasSystemFeature}: The device's audio pipeline is low-latency,
842 | * more suitable for audio applications sensitive to delays or lag in sound
843 | * input or output.
844 | */
845 |
846 | /**
847 | * Feature for {@link #getSystemAvailableFeatures} and
848 | * {@link #hasSystemFeature}: The device supports live wallpapers.
849 | */
850 | public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
851 |
852 | /**
853 | * Feature for {@link #getSystemAvailableFeatures} and
854 | * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
855 | */
856 | public static final String FEATURE_WIFI = "android.hardware.wifi";
857 |
858 | /**
859 | * Feature for {@link #getSystemAvailableFeatures} and
860 | * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
861 | */
862 | public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
863 |
864 | /**
865 | * Action to external storage service to clean out removed apps.
866 | *
867 | * @hide
868 | */
869 | public static final String ACTION_CLEAN_EXTERNAL_STORAGE = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
870 |
871 | /**
872 | * Extra field name for the URI to a verification file. Passed to a package
873 | * verifier.
874 | *
875 | * @hide
876 | */
877 | public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
878 |
879 | /**
880 | * Extra field name for the ID of a package pending verification. Passed to
881 | * a package verifier and is used to call back to
882 | * {@link PackageManager#verifyPendingInstall(int, int)}
883 | */
884 | public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
885 |
886 | /**
887 | * Extra field name for the package identifier which is trying to install
888 | * the package.
889 | *
890 | * @hide
891 | */
892 | public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
893 |
894 | /**
895 | * Extra field name for the requested install flags for a package pending
896 | * verification. Passed to a package verifier.
897 | *
898 | * @hide
899 | */
900 | public static final String EXTRA_VERIFICATION_INSTALL_FLAGS = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
901 |
902 | /**
903 | * Retrieve overall information about an application package that is
904 | * installed on the system.
905 | *
906 | * Throws {@link NameNotFoundException} if a package with the given name can
907 | * not be found on the system.
908 | *
909 | * @param packageName
910 | * The full name (i.e. com.google.apps.contacts) of the desired
911 | * package.
912 | * @param flags
913 | * Additional option flags. Use any combination of
914 | * {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
915 | * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
916 | * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
917 | * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
918 | * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
919 | * modify the data returned.
920 | * @return Returns a PackageInfo object containing information about the
921 | * package. If flag GET_UNINSTALLED_PACKAGES is set and if the
922 | * package is not found in the list of installed applications, the
923 | * package information is retrieved from the list of uninstalled
924 | * applications(which includes installed applications as well as
925 | * applications with data directory ie applications which had been
926 | * deleted with DONT_DELTE_DATA flag set).
927 | * @see #GET_ACTIVITIES
928 | * @see #GET_GIDS
929 | * @see #GET_CONFIGURATIONS
930 | * @see #GET_INSTRUMENTATION
931 | * @see #GET_PERMISSIONS
932 | * @see #GET_PROVIDERS
933 | * @see #GET_RECEIVERS
934 | * @see #GET_SERVICES
935 | * @see #GET_SIGNATURES
936 | * @see #GET_UNINSTALLED_PACKAGES
937 | */
938 | public abstract PackageInfo getPackageInfo(String packageName, int flags)
939 | throws NameNotFoundException;
940 |
941 | /**
942 | * Map from the current package names in use on the device to whatever the
943 | * current canonical name of that package is.
944 | *
945 | * @param names
946 | * Array of current names to be mapped.
947 | * @return Returns an array of the same size as the original, containing the
948 | * canonical name for each package.
949 | */
950 | public abstract String[] currentToCanonicalPackageNames(String[] names);
951 |
952 | /**
953 | * Map from a packages canonical name to the current name in use on the
954 | * device.
955 | *
956 | * @param names
957 | * Array of new names to be mapped.
958 | * @return Returns an array of the same size as the original, containing the
959 | * current name for each package.
960 | */
961 | public abstract String[] canonicalToCurrentPackageNames(String[] names);
962 |
963 | /**
964 | * Return a "good" intent to launch a front-door activity in a package, for
965 | * use for example to implement an "open" button when browsing through
966 | * packages. The current implementation will look first for a main activity
967 | * in the category {@link Intent#CATEGORY_INFO}, next for a main activity in
968 | * the category {@link Intent#CATEGORY_LAUNCHER}, or return null if neither
969 | * are found.
970 | *
971 | *
972 | * Throws {@link NameNotFoundException} if a package with the given name can
973 | * not be found on the system.
974 | *
975 | * @param packageName
976 | * The name of the package to inspect.
977 | *
978 | * @return Returns either a fully-qualified Intent that can be used to
979 | * launch the main activity in the package, or null if the package
980 | * does not contain such an activity.
981 | */
982 | public abstract Intent getLaunchIntentForPackage(String packageName);
983 |
984 | /**
985 | * Return an array of all of the secondary group-ids that have been assigned
986 | * to a package.
987 | *
988 | *
989 | * Throws {@link NameNotFoundException} if a package with the given name can
990 | * not be found on the system.
991 | *
992 | * @param packageName
993 | * The full name (i.e. com.google.apps.contacts) of the desired
994 | * package.
995 | *
996 | * @return Returns an int array of the assigned gids, or null if there are
997 | * none.
998 | */
999 | public abstract int[] getPackageGids(String packageName)
1000 | throws NameNotFoundException;
1001 |
1002 | /**
1003 | * Retrieve all of the information we know about a particular permission.
1004 | *
1005 | *
1006 | * Throws {@link NameNotFoundException} if a permission with the given name
1007 | * can not be found on the system.
1008 | *
1009 | * @param name
1010 | * The fully qualified name (i.e. com.google.permission.LOGIN) of
1011 | * the permission you are interested in.
1012 | * @param flags
1013 | * Additional option flags. Use {@link #GET_META_DATA} to
1014 | * retrieve any meta-data associated with the permission.
1015 | *
1016 | * @return Returns a {@link PermissionInfo} containing information about the
1017 | * permission.
1018 | */
1019 | public abstract PermissionInfo getPermissionInfo(String name, int flags)
1020 | throws NameNotFoundException;
1021 |
1022 | /**
1023 | * Query for all of the permissions associated with a particular group.
1024 | *
1025 | *
1026 | * Throws {@link NameNotFoundException} if the given group does not exist.
1027 | *
1028 | * @param group
1029 | * The fully qualified name (i.e. com.google.permission.LOGIN) of
1030 | * the permission group you are interested in. Use null to find
1031 | * all of the permissions not associated with a group.
1032 | * @param flags
1033 | * Additional option flags. Use {@link #GET_META_DATA} to
1034 | * retrieve any meta-data associated with the permissions.
1035 | *
1036 | * @return Returns a list of {@link PermissionInfo} containing information
1037 | * about all of the permissions in the given group.
1038 | */
1039 | public abstract List queryPermissionsByGroup(String group,
1040 | int flags) throws NameNotFoundException;
1041 |
1042 | /**
1043 | * Retrieve all of the information we know about a particular group of
1044 | * permissions.
1045 | *
1046 | *
1047 | * Throws {@link NameNotFoundException} if a permission group with the given
1048 | * name can not be found on the system.
1049 | *
1050 | * @param name
1051 | * The fully qualified name (i.e.
1052 | * com.google.permission_group.APPS) of the permission you are
1053 | * interested in.
1054 | * @param flags
1055 | * Additional option flags. Use {@link #GET_META_DATA} to
1056 | * retrieve any meta-data associated with the permission group.
1057 | *
1058 | * @return Returns a {@link PermissionGroupInfo} containing information
1059 | * about the permission.
1060 | */
1061 | public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1062 | int flags) throws NameNotFoundException;
1063 |
1064 | /**
1065 | * Retrieve all of the known permission groups in the system.
1066 | *
1067 | * @param flags
1068 | * Additional option flags. Use {@link #GET_META_DATA} to
1069 | * retrieve any meta-data associated with the permission group.
1070 | *
1071 | * @return Returns a list of {@link PermissionGroupInfo} containing
1072 | * information about all of the known permission groups.
1073 | */
1074 | public abstract List getAllPermissionGroups(int flags);
1075 |
1076 | /**
1077 | * Retrieve all of the information we know about a particular
1078 | * package/application.
1079 | *
1080 | *
1081 | * Throws {@link NameNotFoundException} if an application with the given
1082 | * package name can not be found on the system.
1083 | *
1084 | * @param packageName
1085 | * The full name (i.e. com.google.apps.contacts) of an
1086 | * application.
1087 | * @param flags
1088 | * Additional option flags. Use any combination of
1089 | * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1090 | * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1091 | *
1092 | * @return {@link ApplicationInfo} Returns ApplicationInfo object containing
1093 | * information about the package. If flag GET_UNINSTALLED_PACKAGES
1094 | * is set and if the package is not found in the list of installed
1095 | * applications, the application information is retrieved from the
1096 | * list of uninstalled applications(which includes installed
1097 | * applications as well as applications with data directory ie
1098 | * applications which had been deleted with DONT_DELTE_DATA flag
1099 | * set).
1100 | *
1101 | * @see #GET_META_DATA
1102 | * @see #GET_SHARED_LIBRARY_FILES
1103 | * @see #GET_UNINSTALLED_PACKAGES
1104 | */
1105 | public abstract ApplicationInfo getApplicationInfo(String packageName,
1106 | int flags) throws NameNotFoundException;
1107 |
1108 | /**
1109 | * Retrieve all of the information we know about a particular activity
1110 | * class.
1111 | *
1112 | *
1113 | * Throws {@link NameNotFoundException} if an activity with the given class
1114 | * name can not be found on the system.
1115 | *
1116 | * @param component
1117 | * The full component name (i.e.
1118 | * com.google.apps.contacts/com.google
1119 | * .apps.contacts.ContactsList) of an Activity class.
1120 | * @param flags
1121 | * Additional option flags. Use any combination of
1122 | * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, to
1123 | * modify the data (in ApplicationInfo) returned.
1124 | *
1125 | * @return {@link ActivityInfo} containing information about the activity.
1126 | *
1127 | * @see #GET_INTENT_FILTERS
1128 | * @see #GET_META_DATA
1129 | * @see #GET_SHARED_LIBRARY_FILES
1130 | */
1131 | public abstract ActivityInfo getActivityInfo(ComponentName component,
1132 | int flags) throws NameNotFoundException;
1133 |
1134 | /**
1135 | * Retrieve all of the information we know about a particular receiver
1136 | * class.
1137 | *
1138 | *
1139 | * Throws {@link NameNotFoundException} if a receiver with the given class
1140 | * name can not be found on the system.
1141 | *
1142 | * @param component
1143 | * The full component name (i.e.
1144 | * com.google.apps.calendar/com.google
1145 | * .apps.calendar.CalendarAlarm) of a Receiver class.
1146 | * @param flags
1147 | * Additional option flags. Use any combination of
1148 | * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, to
1149 | * modify the data returned.
1150 | *
1151 | * @return {@link ActivityInfo} containing information about the receiver.
1152 | *
1153 | * @see #GET_INTENT_FILTERS
1154 | * @see #GET_META_DATA
1155 | * @see #GET_SHARED_LIBRARY_FILES
1156 | */
1157 | public abstract ActivityInfo getReceiverInfo(ComponentName component,
1158 | int flags) throws NameNotFoundException;
1159 |
1160 | /**
1161 | * Retrieve all of the information we know about a particular service class.
1162 | *
1163 | *
1164 | * Throws {@link NameNotFoundException} if a service with the given class
1165 | * name can not be found on the system.
1166 | *
1167 | * @param component
1168 | * The full component name (i.e.
1169 | * com.google.apps.media/com.google.
1170 | * apps.media.BackgroundPlayback) of a Service class.
1171 | * @param flags
1172 | * Additional option flags. Use any combination of
1173 | * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, to
1174 | * modify the data returned.
1175 | *
1176 | * @return ServiceInfo containing information about the service.
1177 | *
1178 | * @see #GET_META_DATA
1179 | * @see #GET_SHARED_LIBRARY_FILES
1180 | */
1181 | public abstract ServiceInfo getServiceInfo(ComponentName component,
1182 | int flags) throws NameNotFoundException;
1183 |
1184 | /**
1185 | * Retrieve all of the information we know about a particular content
1186 | * provider class.
1187 | *
1188 | *
1189 | * Throws {@link NameNotFoundException} if a provider with the given class
1190 | * name can not be found on the system.
1191 | *
1192 | * @param component
1193 | * The full component name (i.e.
1194 | * com.google.providers.media/com.google
1195 | * .providers.media.MediaProvider) of a ContentProvider class.
1196 | * @param flags
1197 | * Additional option flags. Use any combination of
1198 | * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, to
1199 | * modify the data returned.
1200 | *
1201 | * @return ProviderInfo containing information about the service.
1202 | *
1203 | * @see #GET_META_DATA
1204 | * @see #GET_SHARED_LIBRARY_FILES
1205 | */
1206 | public abstract ProviderInfo getProviderInfo(ComponentName component,
1207 | int flags) throws NameNotFoundException;
1208 |
1209 | /**
1210 | * Return a List of all packages that are installed on the device.
1211 | *
1212 | * @param flags
1213 | * Additional option flags. Use any combination of
1214 | * {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
1215 | * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
1216 | * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
1217 | * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
1218 | * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
1219 | * modify the data returned.
1220 | *
1221 | * @return A List of PackageInfo objects, one for each package that is
1222 | * installed on the device. In the unlikely case of there being no
1223 | * installed packages, an empty list is returned. If flag
1224 | * GET_UNINSTALLED_PACKAGES is set, a list of all applications
1225 | * including those deleted with DONT_DELETE_DATA (partially
1226 | * installed apps with data directory) will be returned.
1227 | *
1228 | * @see #GET_ACTIVITIES
1229 | * @see #GET_GIDS
1230 | * @see #GET_CONFIGURATIONS
1231 | * @see #GET_INSTRUMENTATION
1232 | * @see #GET_PERMISSIONS
1233 | * @see #GET_PROVIDERS
1234 | * @see #GET_RECEIVERS
1235 | * @see #GET_SERVICES
1236 | * @see #GET_SIGNATURES
1237 | * @see #GET_UNINSTALLED_PACKAGES
1238 | *
1239 | */
1240 | public abstract List getInstalledPackages(int flags);
1241 |
1242 | /**
1243 | * Check whether a particular package has been granted a particular
1244 | * permission.
1245 | *
1246 | * @param permName
1247 | * The name of the permission you are checking for,
1248 | * @param pkgName
1249 | * The name of the package you are checking against.
1250 | *
1251 | * @return If the package has the permission, PERMISSION_GRANTED is
1252 | * returned. If it does not have the permission, PERMISSION_DENIED
1253 | * is returned.
1254 | *
1255 | * @see #PERMISSION_GRANTED
1256 | * @see #PERMISSION_DENIED
1257 | */
1258 | public abstract int checkPermission(String permName, String pkgName);
1259 |
1260 | /**
1261 | * Add a new dynamic permission to the system. For this to work, your
1262 | * package must have defined a permission tree through the
1263 | * {@link android.R.styleable#AndroidManifestPermissionTree
1264 | * <permission-tree>} tag in its manifest. A package can only add
1265 | * permissions to trees that were defined by either its own package or
1266 | * another with the same user id; a permission is in a tree if it matches
1267 | * the name of the permission tree + ".": for example, "com.foo.bar" is a
1268 | * member of the permission tree "com.foo".
1269 | *
1270 | *
1271 | * It is good to make your permission tree name descriptive, because you are
1272 | * taking possession of that entire set of permission names. Thus, it must
1273 | * be under a domain you control, with a suffix that will not match any
1274 | * normal permissions that may be declared in any applications that are part
1275 | * of that domain.
1276 | *
1277 | *
1278 | * New permissions must be added before any .apks are installed that use
1279 | * those permissions. Permissions you add through this method are remembered
1280 | * across reboots of the device. If the given permission already exists, the
1281 | * info you supply here will be used to update it.
1282 | *
1283 | * @param info
1284 | * Description of the permission to be added.
1285 | *
1286 | * @return Returns true if a new permission was created, false if an
1287 | * existing one was updated.
1288 | *
1289 | * @throws SecurityException
1290 | * if you are not allowed to add the given permission name.
1291 | *
1292 | * @see #removePermission(String)
1293 | */
1294 | public abstract boolean addPermission(PermissionInfo info);
1295 |
1296 | /**
1297 | * Like {@link #addPermission(PermissionInfo)} but asynchronously persists
1298 | * the package manager state after returning from the call, allowing it to
1299 | * return quicker and batch a series of adds at the expense of no guarantee
1300 | * the added permission will be retained if the device is rebooted before it
1301 | * is written.
1302 | */
1303 | public abstract boolean addPermissionAsync(PermissionInfo info);
1304 |
1305 | /**
1306 | * Removes a permission that was previously added with
1307 | * {@link #addPermission(PermissionInfo)}. The same ownership rules apply --
1308 | * you are only allowed to remove permissions that you are allowed to add.
1309 | *
1310 | * @param name
1311 | * The name of the permission to remove.
1312 | *
1313 | * @throws SecurityException
1314 | * if you are not allowed to remove the given permission name.
1315 | *
1316 | * @see #addPermission(PermissionInfo)
1317 | */
1318 | public abstract void removePermission(String name);
1319 |
1320 | /**
1321 | * Compare the signatures of two packages to determine if the same signature
1322 | * appears in both of them. If they do contain the same signature, then they
1323 | * are allowed special privileges when working with each other: they can
1324 | * share the same user-id, run instrumentation against each other, etc.
1325 | *
1326 | * @param pkg1
1327 | * First package name whose signature will be compared.
1328 | * @param pkg2
1329 | * Second package name whose signature will be compared.
1330 | *
1331 | * @return Returns an integer indicating whether all signatures on the two
1332 | * packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1333 | * all signatures match or < 0 if there is not a match (
1334 | * {@link #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}
1335 | * ).
1336 | *
1337 | * @see #checkSignatures(int, int)
1338 | * @see #SIGNATURE_MATCH
1339 | * @see #SIGNATURE_NO_MATCH
1340 | * @see #SIGNATURE_UNKNOWN_PACKAGE
1341 | */
1342 | public abstract int checkSignatures(String pkg1, String pkg2);
1343 |
1344 | /**
1345 | * Like {@link #checkSignatures(String, String)}, but takes UIDs of the two
1346 | * packages to be checked. This can be useful, for example, when doing the
1347 | * check in an IPC, where the UID is the only identity available. It is
1348 | * functionally identical to determining the package associated with the
1349 | * UIDs and checking their signatures.
1350 | *
1351 | * @param uid1
1352 | * First UID whose signature will be compared.
1353 | * @param uid2
1354 | * Second UID whose signature will be compared.
1355 | *
1356 | * @return Returns an integer indicating whether all signatures on the two
1357 | * packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1358 | * all signatures match or < 0 if there is not a match (
1359 | * {@link #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}
1360 | * ).
1361 | *
1362 | * @see #checkSignatures(String, String)
1363 | * @see #SIGNATURE_MATCH
1364 | * @see #SIGNATURE_NO_MATCH
1365 | * @see #SIGNATURE_UNKNOWN_PACKAGE
1366 | */
1367 | public abstract int checkSignatures(int uid1, int uid2);
1368 |
1369 | /**
1370 | * Retrieve the names of all packages that are associated with a particular
1371 | * user id. In most cases, this will be a single package name, the package
1372 | * that has been assigned that user id. Where there are multiple packages
1373 | * sharing the same user id through the "sharedUserId" mechanism, all
1374 | * packages with that id will be returned.
1375 | *
1376 | * @param uid
1377 | * The user id for which you would like to retrieve the
1378 | * associated packages.
1379 | *
1380 | * @return Returns an array of one or more packages assigned to the user id,
1381 | * or null if there are no known packages with the given id.
1382 | */
1383 | public abstract String[] getPackagesForUid(int uid);
1384 |
1385 | /**
1386 | * Retrieve the official name associated with a user id. This name is
1387 | * guaranteed to never change, though it is possibly for the underlying user
1388 | * id to be changed. That is, if you are storing information about user ids
1389 | * in persistent storage, you should use the string returned by this
1390 | * function instead of the raw user-id.
1391 | *
1392 | * @param uid
1393 | * The user id for which you would like to retrieve a name.
1394 | * @return Returns a unique name for the given user id, or null if the user
1395 | * id is not currently assigned.
1396 | */
1397 | public abstract String getNameForUid(int uid);
1398 |
1399 | /**
1400 | * Return the user id associated with a shared user name. Multiple
1401 | * applications can specify a shared user name in their manifest and thus
1402 | * end up using a common uid. This might be used for new applications that
1403 | * use an existing shared user name and need to know the uid of the shared
1404 | * user.
1405 | *
1406 | * @param sharedUserName
1407 | * The shared user name whose uid is to be retrieved.
1408 | * @return Returns the uid associated with the shared user, or
1409 | * NameNotFoundException if the shared user name is not being used
1410 | * by any installed packages
1411 | * @hide
1412 | */
1413 | public abstract int getUidForSharedUser(String sharedUserName)
1414 | throws NameNotFoundException;
1415 |
1416 | /**
1417 | * Return a List of all application packages that are installed on the
1418 | * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
1419 | * applications including those deleted with DONT_DELETE_DATA(partially
1420 | * installed apps with data directory) will be returned.
1421 | *
1422 | * @param flags
1423 | * Additional option flags. Use any combination of
1424 | * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1425 | * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1426 | *
1427 | * @return A List of ApplicationInfo objects, one for each application that
1428 | * is installed on the device. In the unlikely case of there being
1429 | * no installed applications, an empty list is returned. If flag
1430 | * GET_UNINSTALLED_PACKAGES is set, a list of all applications
1431 | * including those deleted with DONT_DELETE_DATA (partially
1432 | * installed apps with data directory) will be returned.
1433 | *
1434 | * @see #GET_META_DATA
1435 | * @see #GET_SHARED_LIBRARY_FILES
1436 | * @see #GET_UNINSTALLED_PACKAGES
1437 | */
1438 | public abstract List getInstalledApplications(int flags);
1439 |
1440 | /**
1441 | * Get a list of shared libraries that are available on the system.
1442 | *
1443 | * @return An array of shared library names that are available on the
1444 | * system, or null if none are installed.
1445 | *
1446 | */
1447 | public abstract String[] getSystemSharedLibraryNames();
1448 |
1449 | /**
1450 | * Get a list of features that are available on the system.
1451 | *
1452 | * @return An array of FeatureInfo classes describing the features that are
1453 | * available on the system, or null if there are none(!!).
1454 | */
1455 | public abstract FeatureInfo[] getSystemAvailableFeatures();
1456 |
1457 | /**
1458 | * Check whether the given feature name is one of the available features as
1459 | * returned by {@link #getSystemAvailableFeatures()}.
1460 | *
1461 | * @return Returns true if the devices supports the feature, else false.
1462 | */
1463 | public abstract boolean hasSystemFeature(String name);
1464 |
1465 | /**
1466 | * Determine the best action to perform for a given Intent. This is how
1467 | * {@link Intent#resolveActivity} finds an activity if a class has not been
1468 | * explicitly specified.
1469 | *
1470 | *
1471 | * Note: if using an implicit Intent (without an explicit
1472 | * ComponentName specified), be sure to consider whether to set the
1473 | * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
1474 | * activity in the same way that
1475 | * {@link android.content.Context#startActivity(Intent)} and
1476 | * {@link android.content.Intent#resolveActivity(PackageManager)
1477 | * Intent.resolveActivity(PackageManager)} do.
1478 | *
1479 | *
1480 | * @param intent
1481 | * An intent containing all of the desired specification (action,
1482 | * data, type, category, and/or component).
1483 | * @param flags
1484 | * Additional option flags. The most important is
1485 | * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1486 | * those activities that support the
1487 | * {@link android.content.Intent#CATEGORY_DEFAULT}.
1488 | *
1489 | * @return Returns a ResolveInfo containing the final activity intent that
1490 | * was determined to be the best action. Returns null if no matching
1491 | * activity was found. If multiple matching activities are found and
1492 | * there is no default set, returns a ResolveInfo containing
1493 | * something else, such as the activity resolver.
1494 | *
1495 | * @see #MATCH_DEFAULT_ONLY
1496 | * @see #GET_INTENT_FILTERS
1497 | * @see #GET_RESOLVED_FILTER
1498 | */
1499 | public abstract ResolveInfo resolveActivity(Intent intent, int flags);
1500 |
1501 | /**
1502 | * Retrieve all activities that can be performed for the given intent.
1503 | *
1504 | * @param intent
1505 | * The desired intent as per resolveActivity().
1506 | * @param flags
1507 | * Additional option flags. The most important is
1508 | * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1509 | * those activities that support the
1510 | * {@link android.content.Intent#CATEGORY_DEFAULT}.
1511 | *
1512 | * @return A List<ResolveInfo> containing one entry for each matching
1513 | * Activity. These are ordered from best to worst match -- that is,
1514 | * the first item in the list is what is returned by
1515 | * {@link #resolveActivity}. If there are no matching activities, an
1516 | * empty list is returned.
1517 | *
1518 | * @see #MATCH_DEFAULT_ONLY
1519 | * @see #GET_INTENT_FILTERS
1520 | * @see #GET_RESOLVED_FILTER
1521 | */
1522 | public abstract List queryIntentActivities(Intent intent,
1523 | int flags);
1524 |
1525 | /**
1526 | * Retrieve a set of activities that should be presented to the user as
1527 | * similar options. This is like {@link #queryIntentActivities}, except it
1528 | * also allows you to supply a list of more explicit Intents that you would
1529 | * like to resolve to particular options, and takes care of returning the
1530 | * final ResolveInfo list in a reasonable order, with no duplicates, based
1531 | * on those inputs.
1532 | *
1533 | * @param caller
1534 | * The class name of the activity that is making the request.
1535 | * This activity will never appear in the output list. Can be
1536 | * null.
1537 | * @param specifics
1538 | * An array of Intents that should be resolved to the first
1539 | * specific results. Can be null.
1540 | * @param intent
1541 | * The desired intent as per resolveActivity().
1542 | * @param flags
1543 | * Additional option flags. The most important is
1544 | * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1545 | * those activities that support the
1546 | * {@link android.content.Intent#CATEGORY_DEFAULT}.
1547 | *
1548 | * @return A List<ResolveInfo> containing one entry for each matching
1549 | * Activity. These are ordered first by all of the intents resolved
1550 | * in specifics and then any additional activities that
1551 | * can handle intent but did not get included by one of
1552 | * the specifics intents. If there are no matching
1553 | * activities, an empty list is returned.
1554 | *
1555 | * @see #MATCH_DEFAULT_ONLY
1556 | * @see #GET_INTENT_FILTERS
1557 | * @see #GET_RESOLVED_FILTER
1558 | */
1559 | public abstract List queryIntentActivityOptions(
1560 | ComponentName caller, Intent[] specifics, Intent intent, int flags);
1561 |
1562 | /**
1563 | * Retrieve all receivers that can handle a broadcast of the given intent.
1564 | *
1565 | * @param intent
1566 | * The desired intent as per resolveActivity().
1567 | * @param flags
1568 | * Additional option flags.
1569 | *
1570 | * @return A List<ResolveInfo> containing one entry for each matching
1571 | * Receiver. These are ordered from first to last in priority. If
1572 | * there are no matching receivers, an empty list is returned.
1573 | *
1574 | * @see #MATCH_DEFAULT_ONLY
1575 | * @see #GET_INTENT_FILTERS
1576 | * @see #GET_RESOLVED_FILTER
1577 | */
1578 | public abstract List queryBroadcastReceivers(Intent intent,
1579 | int flags);
1580 |
1581 | /**
1582 | * Determine the best service to handle for a given Intent.
1583 | *
1584 | * @param intent
1585 | * An intent containing all of the desired specification (action,
1586 | * data, type, category, and/or component).
1587 | * @param flags
1588 | * Additional option flags.
1589 | *
1590 | * @return Returns a ResolveInfo containing the final service intent that
1591 | * was determined to be the best action. Returns null if no matching
1592 | * service was found.
1593 | *
1594 | * @see #GET_INTENT_FILTERS
1595 | * @see #GET_RESOLVED_FILTER
1596 | */
1597 | public abstract ResolveInfo resolveService(Intent intent, int flags);
1598 |
1599 | /**
1600 | * Retrieve all services that can match the given intent.
1601 | *
1602 | * @param intent
1603 | * The desired intent as per resolveService().
1604 | * @param flags
1605 | * Additional option flags.
1606 | *
1607 | * @return A List<ResolveInfo> containing one entry for each matching
1608 | * ServiceInfo. These are ordered from best to worst match -- that
1609 | * is, the first item in the list is what is returned by
1610 | * resolveService(). If there are no matching services, an empty
1611 | * list is returned.
1612 | *
1613 | * @see #GET_INTENT_FILTERS
1614 | * @see #GET_RESOLVED_FILTER
1615 | */
1616 | public abstract List queryIntentServices(Intent intent,
1617 | int flags);
1618 |
1619 | /**
1620 | * Find a single content provider by its base path name.
1621 | *
1622 | * @param name
1623 | * The name of the provider to find.
1624 | * @param flags
1625 | * Additional option flags. Currently should always be 0.
1626 | *
1627 | * @return ContentProviderInfo Information about the provider, if found,
1628 | * else null.
1629 | */
1630 | public abstract ProviderInfo resolveContentProvider(String name, int flags);
1631 |
1632 | /**
1633 | * Retrieve content provider information.
1634 | *
1635 | *
1636 | * Note: unlike most other methods, an empty result set is indicated
1637 | * by a null return instead of an empty list.
1638 | *
1639 | * @param processName
1640 | * If non-null, limits the returned providers to only those that
1641 | * are hosted by the given process. If null, all content
1642 | * providers are returned.
1643 | * @param uid
1644 | * If processName is non-null, this is the required
1645 | * uid owning the requested content providers.
1646 | * @param flags
1647 | * Additional option flags. Currently should always be 0.
1648 | *
1649 | * @return A List<ContentProviderInfo> containing one entry for each
1650 | * content provider either patching processName or, if
1651 | * processName is null, all known content providers.
1652 | * If there are no matching providers, null is returned.
1653 | */
1654 | public abstract List queryContentProviders(
1655 | String processName, int uid, int flags);
1656 |
1657 | /**
1658 | * Retrieve all of the information we know about a particular
1659 | * instrumentation class.
1660 | *
1661 | *
1662 | * Throws {@link NameNotFoundException} if instrumentation with the given
1663 | * class name can not be found on the system.
1664 | *
1665 | * @param className
1666 | * The full name (i.e. com.google.apps.contacts.InstrumentList)
1667 | * of an Instrumentation class.
1668 | * @param flags
1669 | * Additional option flags. Currently should always be 0.
1670 | *
1671 | * @return InstrumentationInfo containing information about the
1672 | * instrumentation.
1673 | */
1674 | public abstract InstrumentationInfo getInstrumentationInfo(
1675 | ComponentName className, int flags) throws NameNotFoundException;
1676 |
1677 | /**
1678 | * Retrieve information about available instrumentation code. May be used to
1679 | * retrieve either all instrumentation code, or only the code targeting a
1680 | * particular package.
1681 | *
1682 | * @param targetPackage
1683 | * If null, all instrumentation is returned; only the
1684 | * instrumentation targeting this package name is returned.
1685 | * @param flags
1686 | * Additional option flags. Currently should always be 0.
1687 | *
1688 | * @return A List<InstrumentationInfo> containing one entry for each
1689 | * matching available Instrumentation. Returns an empty list if
1690 | * there is no instrumentation available for the given package.
1691 | */
1692 | public abstract List queryInstrumentation(
1693 | String targetPackage, int flags);
1694 |
1695 | /**
1696 | * Retrieve an image from a package. This is a low-level API used by the
1697 | * various package manager info structures (such as {@link ComponentInfo} to
1698 | * implement retrieval of their associated icon.
1699 | *
1700 | * @param packageName
1701 | * The name of the package that this icon is coming from. Can not
1702 | * be null.
1703 | * @param resid
1704 | * The resource identifier of the desired image. Can not be 0.
1705 | * @param appInfo
1706 | * Overall information about packageName. This may be
1707 | * null, in which case the application information will be
1708 | * retrieved for you if needed; if you already have this
1709 | * information around, it can be much more efficient to supply it
1710 | * here.
1711 | *
1712 | * @return Returns a Drawable holding the requested image. Returns null if
1713 | * an image could not be found for any reason.
1714 | */
1715 | public abstract Drawable getDrawable(String packageName, int resid,
1716 | ApplicationInfo appInfo);
1717 |
1718 | /**
1719 | * Retrieve the icon associated with an activity. Given the full name of an
1720 | * activity, retrieves the information about it and calls
1721 | * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
1722 | * icon. If the activity can not be found, NameNotFoundException is thrown.
1723 | *
1724 | * @param activityName
1725 | * Name of the activity whose icon is to be retrieved.
1726 | *
1727 | * @return Returns the image of the icon, or the default activity icon if it
1728 | * could not be found. Does not return null.
1729 | * @throws NameNotFoundException
1730 | * Thrown if the resources for the given activity could not be
1731 | * loaded.
1732 | *
1733 | * @see #getActivityIcon(Intent)
1734 | */
1735 | public abstract Drawable getActivityIcon(ComponentName activityName)
1736 | throws NameNotFoundException;
1737 |
1738 | /**
1739 | * Retrieve the icon associated with an Intent. If intent.getClassName() is
1740 | * set, this simply returns the result of
1741 | * getActivityIcon(intent.getClassName()). Otherwise it resolves the
1742 | * intent's component and returns the icon associated with the resolved
1743 | * component. If intent.getClassName() can not be found or the Intent can
1744 | * not be resolved to a component, NameNotFoundException is thrown.
1745 | *
1746 | * @param intent
1747 | * The intent for which you would like to retrieve an icon.
1748 | *
1749 | * @return Returns the image of the icon, or the default activity icon if it
1750 | * could not be found. Does not return null.
1751 | * @throws NameNotFoundException
1752 | * Thrown if the resources for application matching the given
1753 | * intent could not be loaded.
1754 | *
1755 | * @see #getActivityIcon(ComponentName)
1756 | */
1757 | public abstract Drawable getActivityIcon(Intent intent)
1758 | throws NameNotFoundException;
1759 |
1760 | /**
1761 | * Return the generic icon for an activity that is used when no specific
1762 | * icon is defined.
1763 | *
1764 | * @return Drawable Image of the icon.
1765 | */
1766 | public abstract Drawable getDefaultActivityIcon();
1767 |
1768 | /**
1769 | * Retrieve the icon associated with an application. If it has not defined
1770 | * an icon, the default app icon is returned. Does not return null.
1771 | *
1772 | * @param info
1773 | * Information about application being queried.
1774 | *
1775 | * @return Returns the image of the icon, or the default application icon if
1776 | * it could not be found.
1777 | *
1778 | * @see #getApplicationIcon(String)
1779 | */
1780 | public abstract Drawable getApplicationIcon(ApplicationInfo info);
1781 |
1782 | /**
1783 | * Retrieve the icon associated with an application. Given the name of the
1784 | * application's package, retrieves the information about it and calls
1785 | * getApplicationIcon() to return its icon. If the application can not be
1786 | * found, NameNotFoundException is thrown.
1787 | *
1788 | * @param packageName
1789 | * Name of the package whose application icon is to be retrieved.
1790 | *
1791 | * @return Returns the image of the icon, or the default application icon if
1792 | * it could not be found. Does not return null.
1793 | * @throws NameNotFoundException
1794 | * Thrown if the resources for the given application could not
1795 | * be loaded.
1796 | *
1797 | * @see #getApplicationIcon(ApplicationInfo)
1798 | */
1799 | public abstract Drawable getApplicationIcon(String packageName)
1800 | throws NameNotFoundException;
1801 |
1802 | /**
1803 | * Retrieve the logo associated with an activity. Given the full name of an
1804 | * activity, retrieves the information about it and calls
1805 | * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
1806 | * logo. If the activity can not be found, NameNotFoundException is thrown.
1807 | *
1808 | * @param activityName
1809 | * Name of the activity whose logo is to be retrieved.
1810 | *
1811 | * @return Returns the image of the logo or null if the activity has no logo
1812 | * specified.
1813 | *
1814 | * @throws NameNotFoundException
1815 | * Thrown if the resources for the given activity could not be
1816 | * loaded.
1817 | *
1818 | * @see #getActivityLogo(Intent)
1819 | */
1820 | public abstract Drawable getActivityLogo(ComponentName activityName)
1821 | throws NameNotFoundException;
1822 |
1823 | /**
1824 | * Retrieve the logo associated with an Intent. If intent.getClassName() is
1825 | * set, this simply returns the result of
1826 | * getActivityLogo(intent.getClassName()). Otherwise it resolves the
1827 | * intent's component and returns the logo associated with the resolved
1828 | * component. If intent.getClassName() can not be found or the Intent can
1829 | * not be resolved to a component, NameNotFoundException is thrown.
1830 | *
1831 | * @param intent
1832 | * The intent for which you would like to retrieve a logo.
1833 | *
1834 | * @return Returns the image of the logo, or null if the activity has no
1835 | * logo specified.
1836 | *
1837 | * @throws NameNotFoundException
1838 | * Thrown if the resources for application matching the given
1839 | * intent could not be loaded.
1840 | *
1841 | * @see #getActivityLogo(ComponentName)
1842 | */
1843 | public abstract Drawable getActivityLogo(Intent intent)
1844 | throws NameNotFoundException;
1845 |
1846 | /**
1847 | * Retrieve the logo associated with an application. If it has not specified
1848 | * a logo, this method returns null.
1849 | *
1850 | * @param info
1851 | * Information about application being queried.
1852 | *
1853 | * @return Returns the image of the logo, or null if no logo is specified by
1854 | * the application.
1855 | *
1856 | * @see #getApplicationLogo(String)
1857 | */
1858 | public abstract Drawable getApplicationLogo(ApplicationInfo info);
1859 |
1860 | /**
1861 | * Retrieve the logo associated with an application. Given the name of the
1862 | * application's package, retrieves the information about it and calls
1863 | * getApplicationLogo() to return its logo. If the application can not be
1864 | * found, NameNotFoundException is thrown.
1865 | *
1866 | * @param packageName
1867 | * Name of the package whose application logo is to be retrieved.
1868 | *
1869 | * @return Returns the image of the logo, or null if no application logo has
1870 | * been specified.
1871 | *
1872 | * @throws NameNotFoundException
1873 | * Thrown if the resources for the given application could not
1874 | * be loaded.
1875 | *
1876 | * @see #getApplicationLogo(ApplicationInfo)
1877 | */
1878 | public abstract Drawable getApplicationLogo(String packageName)
1879 | throws NameNotFoundException;
1880 |
1881 | /**
1882 | * Retrieve text from a package. This is a low-level API used by the various
1883 | * package manager info structures (such as {@link ComponentInfo} to
1884 | * implement retrieval of their associated labels and other text.
1885 | *
1886 | * @param packageName
1887 | * The name of the package that this text is coming from. Can not
1888 | * be null.
1889 | * @param resid
1890 | * The resource identifier of the desired text. Can not be 0.
1891 | * @param appInfo
1892 | * Overall information about packageName. This may be
1893 | * null, in which case the application information will be
1894 | * retrieved for you if needed; if you already have this
1895 | * information around, it can be much more efficient to supply it
1896 | * here.
1897 | *
1898 | * @return Returns a CharSequence holding the requested text. Returns null
1899 | * if the text could not be found for any reason.
1900 | */
1901 | public abstract CharSequence getText(String packageName, int resid,
1902 | ApplicationInfo appInfo);
1903 |
1904 | /**
1905 | * Retrieve an XML file from a package. This is a low-level API used to
1906 | * retrieve XML meta data.
1907 | *
1908 | * @param packageName
1909 | * The name of the package that this xml is coming from. Can not
1910 | * be null.
1911 | * @param resid
1912 | * The resource identifier of the desired xml. Can not be 0.
1913 | * @param appInfo
1914 | * Overall information about packageName. This may be
1915 | * null, in which case the application information will be
1916 | * retrieved for you if needed; if you already have this
1917 | * information around, it can be much more efficient to supply it
1918 | * here.
1919 | *
1920 | * @return Returns an XmlPullParser allowing you to parse out the XML data.
1921 | * Returns null if the xml resource could not be found for any
1922 | * reason.
1923 | */
1924 | public abstract XmlResourceParser getXml(String packageName, int resid,
1925 | ApplicationInfo appInfo);
1926 |
1927 | /**
1928 | * Return the label to use for this application.
1929 | *
1930 | * @return Returns the label associated with this application, or null if it
1931 | * could not be found for any reason.
1932 | * @param info
1933 | * The application to get the label of
1934 | */
1935 | public abstract CharSequence getApplicationLabel(ApplicationInfo info);
1936 |
1937 | /**
1938 | * Retrieve the resources associated with an activity. Given the full name
1939 | * of an activity, retrieves the information about it and calls
1940 | * getResources() to return its application's resources. If the activity can
1941 | * not be found, NameNotFoundException is thrown.
1942 | *
1943 | * @param activityName
1944 | * Name of the activity whose resources are to be retrieved.
1945 | *
1946 | * @return Returns the application's Resources.
1947 | * @throws NameNotFoundException
1948 | * Thrown if the resources for the given application could not
1949 | * be loaded.
1950 | *
1951 | * @see #getResourcesForApplication(ApplicationInfo)
1952 | */
1953 | public abstract Resources getResourcesForActivity(ComponentName activityName)
1954 | throws NameNotFoundException;
1955 |
1956 | /**
1957 | * Retrieve the resources for an application. Throws NameNotFoundException
1958 | * if the package is no longer installed.
1959 | *
1960 | * @param app
1961 | * Information about the desired application.
1962 | *
1963 | * @return Returns the application's Resources.
1964 | * @throws NameNotFoundException
1965 | * Thrown if the resources for the given application could not
1966 | * be loaded (most likely because it was uninstalled).
1967 | */
1968 | public abstract Resources getResourcesForApplication(ApplicationInfo app)
1969 | throws NameNotFoundException;
1970 |
1971 | /**
1972 | * Retrieve the resources associated with an application. Given the full
1973 | * package name of an application, retrieves the information about it and
1974 | * calls getResources() to return its application's resources. If the
1975 | * appPackageName can not be found, NameNotFoundException is thrown.
1976 | *
1977 | * @param appPackageName
1978 | * Package name of the application whose resources are to be
1979 | * retrieved.
1980 | *
1981 | * @return Returns the application's Resources.
1982 | * @throws NameNotFoundException
1983 | * Thrown if the resources for the given application could not
1984 | * be loaded.
1985 | *
1986 | * @see #getResourcesForApplication(ApplicationInfo)
1987 | */
1988 | public abstract Resources getResourcesForApplication(String appPackageName)
1989 | throws NameNotFoundException;
1990 |
1991 | /**
1992 | * Retrieve overall information about an application package defined in a
1993 | * package archive file
1994 | *
1995 | * @param archiveFilePath
1996 | * The path to the archive file
1997 | * @param flags
1998 | * Additional option flags. Use any combination of
1999 | * {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
2000 | * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
2001 | * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2002 | * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2003 | * {@link #GET_SIGNATURES}, to modify the data returned.
2004 | *
2005 | * @return Returns the information about the package. Returns null if the
2006 | * package could not be successfully parsed.
2007 | *
2008 | * @see #GET_ACTIVITIES
2009 | * @see #GET_GIDS
2010 | * @see #GET_CONFIGURATIONS
2011 | * @see #GET_INSTRUMENTATION
2012 | * @see #GET_PERMISSIONS
2013 | * @see #GET_PROVIDERS
2014 | * @see #GET_RECEIVERS
2015 | * @see #GET_SERVICES
2016 | * @see #GET_SIGNATURES
2017 | *
2018 | */
2019 | public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
2020 | throw new RuntimeException("sub");
2021 | }
2022 |
2023 | /**
2024 | * @hide
2025 | *
2026 | * Install a package. Since this may take a little while, the result
2027 | * will be posted back to the given observer. An installation will
2028 | * fail if the calling context lacks the
2029 | * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
2030 | * the package named in the package file's manifest is already
2031 | * installed, or if there's no space available on the device.
2032 | *
2033 | * @param packageURI
2034 | * The location of the package file to install. This can be a
2035 | * 'file:' or a 'content:' URI.
2036 | * @param observer
2037 | * An observer callback to get notified when the package
2038 | * installation is complete.
2039 | * {@link IPackageInstallObserver#packageInstalled(String, int)}
2040 | * will be called when that happens. observer may be null to
2041 | * indicate that no callback is desired.
2042 | * @param flags
2043 | * - possible values: {@link #INSTALL_FORWARD_LOCK},
2044 | * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}
2045 | * .
2046 | * @param installerPackageName
2047 | * Optional package name of the application that is performing
2048 | * the installation. This identifies which market the package
2049 | * came from.
2050 | */
2051 | public abstract void installPackage(Uri packageURI,
2052 | IPackageInstallObserver observer, int flags,
2053 | String installerPackageName);
2054 |
2055 | /**
2056 | * Similar to
2057 | * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
2058 | * with an extra verification file provided.
2059 | *
2060 | * @param packageURI
2061 | * The location of the package file to install. This can be a
2062 | * 'file:' or a 'content:' URI.
2063 | * @param observer
2064 | * An observer callback to get notified when the package
2065 | * installation is complete.
2066 | * {@link IPackageInstallObserver#packageInstalled(String, int)}
2067 | * will be called when that happens. observer may be null to
2068 | * indicate that no callback is desired.
2069 | * @param flags
2070 | * - possible values: {@link #INSTALL_FORWARD_LOCK},
2071 | * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}
2072 | * .
2073 | * @param installerPackageName
2074 | * Optional package name of the application that is performing
2075 | * the installation. This identifies which market the package
2076 | * came from.
2077 | * @param verificationURI
2078 | * The location of the supplementary verification file. This can
2079 | * be a 'file:' or a 'content:' URI.
2080 | * @hide
2081 | */
2082 | public abstract void installPackageWithVerification(Uri packageURI,
2083 | IPackageInstallObserver observer, int flags,
2084 | String installerPackageName, Uri verificationURI,
2085 | ManifestDigest manifestDigest);
2086 |
2087 | /**
2088 | * Allows a package listening to the
2089 | * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
2090 | * broadcast} to respond to the package manager. The response must include
2091 | * the {@code verificationCode} which is one of
2092 | * {@link PackageManager#VERIFICATION_ALLOW} or
2093 | * {@link PackageManager#VERIFICATION_REJECT}.
2094 | *
2095 | * @param id
2096 | * pending package identifier as passed via the
2097 | * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra
2098 | * @param verificationCode
2099 | * either {@link PackageManager#VERIFICATION_ALLOW} or
2100 | * {@link PackageManager#VERIFICATION_REJECT}.
2101 | */
2102 | public abstract void verifyPendingInstall(int id, int verificationCode);
2103 |
2104 | /**
2105 | * Change the installer associated with a given package. There are
2106 | * limitations on how the installer package can be changed; in particular:
2107 | *
2108 | *
A SecurityException will be thrown if installerPackageName
2109 | * is not signed with the same certificate as the calling application.
2110 | *
A SecurityException will be thrown if targetPackage
2111 | * already has an installer package, and that installer package is not
2112 | * signed with the same certificate as the calling application.
2113 | *
2114 | *
2115 | * @param targetPackage
2116 | * The installed package whose installer will be changed.
2117 | * @param installerPackageName
2118 | * The package name of the new installer. May be null to clear
2119 | * the association.
2120 | */
2121 | public abstract void setInstallerPackageName(String targetPackage,
2122 | String installerPackageName);
2123 |
2124 | /**
2125 | * Attempts to delete a package. Since this may take a little while, the
2126 | * result will be posted back to the given observer. A deletion will fail if
2127 | * the calling context lacks the
2128 | * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
2129 | * named package cannot be found, or if the named package is a
2130 | * "system package". (TODO: include pointer to documentation on
2131 | * "system packages")
2132 | *
2133 | * @param packageName
2134 | * The name of the package to delete
2135 | * @param observer
2136 | * An observer callback to get notified when the package deletion
2137 | * is complete.
2138 | * {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)}
2139 | * will be called when that happens. observer may be null to
2140 | * indicate that no callback is desired.
2141 | * @param flags
2142 | * - possible values: {@link #DONT_DELETE_DATA}
2143 | *
2144 | * @hide
2145 | */
2146 | public abstract void deletePackage(String packageName,
2147 | IPackageDeleteObserver observer, int flags);
2148 |
2149 | /**
2150 | * Retrieve the package name of the application that installed a package.
2151 | * This identifies which market the package came from.
2152 | *
2153 | * @param packageName
2154 | * The name of the package to query
2155 | */
2156 | public abstract String getInstallerPackageName(String packageName);
2157 |
2158 | /**
2159 | * Attempts to clear the user data directory of an application. Since this
2160 | * may take a little while, the result will be posted back to the given
2161 | * observer. A deletion will fail if the named package cannot be found, or
2162 | * if the named package is a "system package".
2163 | *
2164 | * @param packageName
2165 | * The name of the package
2166 | * @param observer
2167 | * An observer callback to get notified when the operation is
2168 | * finished
2169 | * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2170 | * will be called when that happens. observer may be null to
2171 | * indicate that no callback is desired.
2172 | *
2173 | * @hide
2174 | */
2175 | public abstract void clearApplicationUserData(String packageName,
2176 | IPackageDataObserver observer);
2177 |
2178 | /**
2179 | * Attempts to delete the cache files associated with an application. Since
2180 | * this may take a little while, the result will be posted back to the given
2181 | * observer. A deletion will fail if the calling context lacks the
2182 | * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
2183 | * named package cannot be found, or if the named package is a
2184 | * "system package".
2185 | *
2186 | * @param packageName
2187 | * The name of the package to delete
2188 | * @param observer
2189 | * An observer callback to get notified when the cache file
2190 | * deletion is complete.
2191 | * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2192 | * will be called when that happens. observer may be null to
2193 | * indicate that no callback is desired.
2194 | *
2195 | * @hide
2196 | */
2197 | public abstract void deleteApplicationCacheFiles(String packageName,
2198 | IPackageDataObserver observer);
2199 |
2200 | /**
2201 | * Free storage by deleting LRU sorted list of cache files across all
2202 | * applications. If the currently available free storage on the device is
2203 | * greater than or equal to the requested free storage, no cache files are
2204 | * cleared. If the currently available storage on the device is less than
2205 | * the requested free storage, some or all of the cache files across all
2206 | * applications are deleted (based on last accessed time) to increase the
2207 | * free storage space on the device to the requested value. There is no
2208 | * guarantee that clearing all the cache files from all applications will
2209 | * clear up enough storage to achieve the desired value.
2210 | *
2211 | * @param freeStorageSize
2212 | * The number of bytes of storage to be freed by the system. Say
2213 | * if freeStorageSize is XX, and the current free storage is YY,
2214 | * if XX is less than YY, just return. if not free XX-YY number
2215 | * of bytes if possible.
2216 | * @param observer
2217 | * call back used to notify when the operation is completed
2218 | *
2219 | * @hide
2220 | */
2221 | public abstract void freeStorageAndNotify(long freeStorageSize,
2222 | IPackageDataObserver observer);
2223 |
2224 | /**
2225 | * Free storage by deleting LRU sorted list of cache files across all
2226 | * applications. If the currently available free storage on the device is
2227 | * greater than or equal to the requested free storage, no cache files are
2228 | * cleared. If the currently available storage on the device is less than
2229 | * the requested free storage, some or all of the cache files across all
2230 | * applications are deleted (based on last accessed time) to increase the
2231 | * free storage space on the device to the requested value. There is no
2232 | * guarantee that clearing all the cache files from all applications will
2233 | * clear up enough storage to achieve the desired value.
2234 | *
2235 | * @param freeStorageSize
2236 | * The number of bytes of storage to be freed by the system. Say
2237 | * if freeStorageSize is XX, and the current free storage is YY,
2238 | * if XX is less than YY, just return. if not free XX-YY number
2239 | * of bytes if possible.
2240 | * @param pi
2241 | * IntentSender call back used to notify when the operation is
2242 | * completed.May be null to indicate that no call back is
2243 | * desired.
2244 | *
2245 | * @hide
2246 | */
2247 | public abstract void freeStorage(long freeStorageSize, IntentSender pi);
2248 |
2249 | /**
2250 | * Retrieve the size information for a package. Since this may take a little
2251 | * while, the result will be posted back to the given observer. The calling
2252 | * context should have the
2253 | * {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
2254 | *
2255 | * @param packageName
2256 | * The name of the package whose size information is to be
2257 | * retrieved
2258 | * @param observer
2259 | * An observer callback to get notified when the operation is
2260 | * complete.
2261 | * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
2262 | * The observer's callback is invoked with a PackageStats
2263 | * object(containing the code, data and cache sizes of the
2264 | * package) and a boolean value representing the status of the
2265 | * operation. observer may be null to indicate that no callback
2266 | * is desired.
2267 | *
2268 | * @hide
2269 | */
2270 | public abstract void getPackageSizeInfo(String packageName,
2271 | IPackageStatsObserver observer);
2272 |
2273 | /**
2274 | * @deprecated This function no longer does anything; it was an old approach
2275 | * to managing preferred activities, which has been superceeded
2276 | * (and conflicts with) the modern activity-based preferences.
2277 | */
2278 | @Deprecated
2279 | public abstract void addPackageToPreferred(String packageName);
2280 |
2281 | /**
2282 | * @deprecated This function no longer does anything; it was an old approach
2283 | * to managing preferred activities, which has been superceeded
2284 | * (and conflicts with) the modern activity-based preferences.
2285 | */
2286 | @Deprecated
2287 | public abstract void removePackageFromPreferred(String packageName);
2288 |
2289 | /**
2290 | * Retrieve the list of all currently configured preferred packages. The
2291 | * first package on the list is the most preferred, the last is the least
2292 | * preferred.
2293 | *
2294 | * @param flags
2295 | * Additional option flags. Use any combination of
2296 | * {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
2297 | * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
2298 | * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2299 | * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2300 | * {@link #GET_SIGNATURES}, to modify the data returned.
2301 | *
2302 | * @return Returns a list of PackageInfo objects describing each preferred
2303 | * application, in order of preference.
2304 | *
2305 | * @see #GET_ACTIVITIES
2306 | * @see #GET_GIDS
2307 | * @see #GET_CONFIGURATIONS
2308 | * @see #GET_INSTRUMENTATION
2309 | * @see #GET_PERMISSIONS
2310 | * @see #GET_PROVIDERS
2311 | * @see #GET_RECEIVERS
2312 | * @see #GET_SERVICES
2313 | * @see #GET_SIGNATURES
2314 | */
2315 | public abstract List getPreferredPackages(int flags);
2316 |
2317 | /**
2318 | * @deprecated This is a protected API that should not have been available
2319 | * to third party applications. It is the platform's
2320 | * responsibility for assigning preferred activities and this
2321 | * can not be directly modified.
2322 | *
2323 | * Add a new preferred activity mapping to the system. This will
2324 | * be used to automatically select the given activity component
2325 | * when {@link Context#startActivity(Intent)
2326 | * Context.startActivity()} finds multiple matching activities
2327 | * and also matches the given filter.
2328 | *
2329 | * @param filter
2330 | * The set of intents under which this activity will be made
2331 | * preferred.
2332 | * @param match
2333 | * The IntentFilter match category that this preference applies
2334 | * to.
2335 | * @param set
2336 | * The set of activities that the user was picking from when this
2337 | * preference was made.
2338 | * @param activity
2339 | * The component name of the activity that is to be preferred.
2340 | */
2341 | @Deprecated
2342 | public abstract void addPreferredActivity(IntentFilter filter, int match,
2343 | ComponentName[] set, ComponentName activity);
2344 |
2345 | /**
2346 | * @deprecated This is a protected API that should not have been available
2347 | * to third party applications. It is the platform's
2348 | * responsibility for assigning preferred activities and this
2349 | * can not be directly modified.
2350 | *
2351 | * Replaces an existing preferred activity mapping to the
2352 | * system, and if that were not present adds a new preferred
2353 | * activity. This will be used to automatically select the given
2354 | * activity component when {@link Context#startActivity(Intent)
2355 | * Context.startActivity()} finds multiple matching activities
2356 | * and also matches the given filter.
2357 | *
2358 | * @param filter
2359 | * The set of intents under which this activity will be made
2360 | * preferred.
2361 | * @param match
2362 | * The IntentFilter match category that this preference applies
2363 | * to.
2364 | * @param set
2365 | * The set of activities that the user was picking from when this
2366 | * preference was made.
2367 | * @param activity
2368 | * The component name of the activity that is to be preferred.
2369 | * @hide
2370 | */
2371 | @Deprecated
2372 | public abstract void replacePreferredActivity(IntentFilter filter,
2373 | int match, ComponentName[] set, ComponentName activity);
2374 |
2375 | /**
2376 | * Remove all preferred activity mappings, previously added with
2377 | * {@link #addPreferredActivity}, from the system whose activities are
2378 | * implemented in the given package name. An application can only clear its
2379 | * own package(s).
2380 | *
2381 | * @param packageName
2382 | * The name of the package whose preferred activity mappings are
2383 | * to be removed.
2384 | */
2385 | public abstract void clearPackagePreferredActivities(String packageName);
2386 |
2387 | /**
2388 | * Retrieve all preferred activities, previously added with
2389 | * {@link #addPreferredActivity}, that are currently registered with the
2390 | * system.
2391 | *
2392 | * @param outFilters
2393 | * A list in which to place the filters of all of the preferred
2394 | * activities, or null for none.
2395 | * @param outActivities
2396 | * A list in which to place the component names of all of the
2397 | * preferred activities, or null for none.
2398 | * @param packageName
2399 | * An option package in which you would like to limit the list.
2400 | * If null, all activities will be returned; if non-null, only
2401 | * those activities in the given package are returned.
2402 | *
2403 | * @return Returns the total number of registered preferred activities (the
2404 | * number of distinct IntentFilter records, not the number of unique
2405 | * activity components) that were found.
2406 | */
2407 | public abstract int getPreferredActivities(List outFilters,
2408 | List outActivities, String packageName);
2409 |
2410 | /**
2411 | * Set the enabled setting for a package component (activity, receiver,
2412 | * service, provider). This setting will override any enabled state which
2413 | * may have been set by the component in its manifest.
2414 | *
2415 | * @param componentName
2416 | * The component to enable
2417 | * @param newState
2418 | * The new enabled state for the component. The legal values for
2419 | * this state are: {@link #COMPONENT_ENABLED_STATE_ENABLED},
2420 | * {@link #COMPONENT_ENABLED_STATE_DISABLED} and
2421 | * {@link #COMPONENT_ENABLED_STATE_DEFAULT} The last one removes
2422 | * the setting, thereby restoring the component's state to
2423 | * whatever was set in it's manifest (or enabled, by default).
2424 | * @param flags
2425 | * Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2426 | */
2427 | public abstract void setComponentEnabledSetting(
2428 | ComponentName componentName, int newState, int flags);
2429 |
2430 | /**
2431 | * Return the the enabled setting for a package component (activity,
2432 | * receiver, service, provider). This returns the last value set by
2433 | * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
2434 | * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2435 | * the value originally specified in the manifest has not been modified.
2436 | *
2437 | * @param componentName
2438 | * The component to retrieve.
2439 | * @return Returns the current enabled state for the component. May be one
2440 | * of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2441 | * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2442 | * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
2443 | * component's enabled state is based on the original information in
2444 | * the manifest as found in {@link ComponentInfo}.
2445 | */
2446 | public abstract int getComponentEnabledSetting(ComponentName componentName);
2447 |
2448 | /**
2449 | * Set the enabled setting for an application This setting will override any
2450 | * enabled state which may have been set by the application in its manifest.
2451 | * It also overrides the enabled state set in the manifest for any of the
2452 | * application's components. It does not override any enabled state set by
2453 | * {@link #setComponentEnabledSetting} for any of the application's
2454 | * components.
2455 | *
2456 | * @param packageName
2457 | * The package name of the application to enable
2458 | * @param newState
2459 | * The new enabled state for the component. The legal values for
2460 | * this state are: {@link #COMPONENT_ENABLED_STATE_ENABLED},
2461 | * {@link #COMPONENT_ENABLED_STATE_DISABLED} and
2462 | * {@link #COMPONENT_ENABLED_STATE_DEFAULT} The last one removes
2463 | * the setting, thereby restoring the applications's state to
2464 | * whatever was set in its manifest (or enabled, by default).
2465 | * @param flags
2466 | * Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2467 | */
2468 | public abstract void setApplicationEnabledSetting(String packageName,
2469 | int newState, int flags);
2470 |
2471 | /**
2472 | * Return the the enabled setting for an application. This returns the last
2473 | * value set by {@link #setApplicationEnabledSetting(String, int, int)}; in
2474 | * most cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2475 | * since the value originally specified in the manifest has not been
2476 | * modified.
2477 | *
2478 | * @param packageName
2479 | * The component to retrieve.
2480 | * @return Returns the current enabled state for the component. May be one
2481 | * of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2482 | * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2483 | * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
2484 | * application's enabled state is based on the original information
2485 | * in the manifest as found in {@link ComponentInfo}.
2486 | * @throws IllegalArgumentException
2487 | * if the named package does not exist.
2488 | */
2489 | public abstract int getApplicationEnabledSetting(String packageName);
2490 |
2491 | /**
2492 | * Return whether the device has been booted into safe mode.
2493 | */
2494 | public abstract boolean isSafeMode();
2495 |
2496 | /**
2497 | * Attempts to move package resources from internal to external media or
2498 | * vice versa. Since this may take a little while, the result will be posted
2499 | * back to the given observer. This call may fail if the calling context
2500 | * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if
2501 | * the named package cannot be found, or if the named package is a
2502 | * "system package".
2503 | *
2504 | * @param packageName
2505 | * The name of the package to delete
2506 | * @param observer
2507 | * An observer callback to get notified when the package move is
2508 | * complete.
2509 | * {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)}
2510 | * will be called when that happens. observer may be null to
2511 | * indicate that no callback is desired.
2512 | * @param flags
2513 | * To indicate install location {@link #MOVE_INTERNAL} or
2514 | * {@link #MOVE_EXTERNAL_MEDIA}
2515 | *
2516 | * @hide
2517 | */
2518 | public abstract void movePackage(String packageName,
2519 | IPackageMoveObserver observer, int flags);
2520 |
2521 | /**
2522 | * Creates a user with the specified name and options.
2523 | *
2524 | * @param name
2525 | * the user's name
2526 | * @param flags
2527 | * flags that identify the type of user and other properties.
2528 | * @see UserInfo
2529 | *
2530 | * @return the UserInfo object for the created user, or null if the user
2531 | * could not be created.
2532 | * @hide
2533 | */
2534 | public abstract UserInfo createUser(String name, int flags);
2535 |
2536 | /**
2537 | * @return the list of users that were created
2538 | * @hide
2539 | */
2540 | public abstract List getUsers();
2541 |
2542 | /**
2543 | * @param id
2544 | * the ID of the user, where 0 is the primary user.
2545 | * @hide
2546 | */
2547 | public abstract boolean removeUser(int id);
2548 |
2549 | /**
2550 | * Updates the user's name.
2551 | *
2552 | * @param id
2553 | * the user's id
2554 | * @param name
2555 | * the new name for the user
2556 | * @hide
2557 | */
2558 | public abstract void updateUserName(int id, String name);
2559 |
2560 | /**
2561 | * Changes the user's properties specified by the flags.
2562 | *
2563 | * @param id
2564 | * the user's id
2565 | * @param flags
2566 | * the new flags for the user
2567 | * @hide
2568 | */
2569 | public abstract void updateUserFlags(int id, int flags);
2570 |
2571 | /**
2572 | * Checks to see if the user id is the same for the two uids, i.e., they
2573 | * belong to the same user.
2574 | *
2575 | * @hide
2576 | */
2577 | public static boolean isSameUser(int uid1, int uid2) {
2578 | return getUserId(uid1) == getUserId(uid2);
2579 | }
2580 |
2581 | /**
2582 | * Returns the user id for a given uid.
2583 | *
2584 | * @hide
2585 | */
2586 | public static int getUserId(int uid) {
2587 | return uid / PER_USER_RANGE;
2588 | }
2589 |
2590 | /**
2591 | * Returns the uid that is composed from the userId and the appId.
2592 | *
2593 | * @hide
2594 | */
2595 | public static int getUid(int userId, int appId) {
2596 | return userId * PER_USER_RANGE + (appId % PER_USER_RANGE);
2597 | }
2598 |
2599 | /**
2600 | * Returns the app id (or base uid) for a given uid, stripping out the user
2601 | * id from it.
2602 | *
2603 | * @hide
2604 | */
2605 | public static int getAppId(int uid) {
2606 | return uid % PER_USER_RANGE;
2607 | }
2608 |
2609 | /**
2610 | * Returns the device identity that verifiers can use to associate their
2611 | * scheme to a particular device. This should not be used by anything other
2612 | * than a package verifier.
2613 | *
2614 | * @return identity that uniquely identifies current device
2615 | * @hide
2616 | */
2617 | public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
2618 | }
2619 |
--------------------------------------------------------------------------------