├── README.md
├── assets
└── AidlServerDemo.apk
├── project.properties
├── res
├── drawable-hdpi
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── drawable-xxhdpi
│ └── ic_launcher.png
├── layout
│ └── activity_main.xml
└── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── src
├── android
│ ├── annotation
│ │ └── SystemApi.java
│ └── content
│ │ └── pm
│ │ ├── ContainerEncryptionParams.aidl
│ │ ├── IPackageDataObserver.aidl
│ │ ├── IPackageDeleteObserver.aidl
│ │ ├── IPackageDeleteObserver2.aidl
│ │ ├── IPackageInstallObserver.aidl
│ │ ├── IPackageInstallObserver2.aidl
│ │ ├── IPackageInstaller.aidl
│ │ ├── IPackageInstallerCallback.aidl
│ │ ├── IPackageInstallerSession.aidl
│ │ ├── IPackageManager.aidl
│ │ ├── IPackageMoveObserver.aidl
│ │ ├── IPackageStatsObserver.aidl
│ │ ├── KeySet.aidl
│ │ ├── KeySet.java
│ │ ├── ManifestDigest.aidl
│ │ ├── ManifestDigest.java
│ │ ├── PackageCleanItem.aidl
│ │ ├── PackageCleanItem.java
│ │ ├── PackageInstaller.aidl
│ │ ├── ParceledListSlice.aidl
│ │ ├── ParceledListSlice.java
│ │ ├── UserInfo.aidl
│ │ ├── VerificationParams.aidl
│ │ ├── VerificationParams.java
│ │ ├── VerifierDeviceIdentity.aidl
│ │ └── VerifierDeviceIdentity.java
└── com
│ └── example
│ └── autoinstall
│ ├── FileUtils.java
│ └── MainActivity.java
└── 系统签名
├── AutoInstall.apk
├── AutoInstall_new.apk
├── SignApk.jar
├── platform.pk8
└── platform.x509.pem
/README.md:
--------------------------------------------------------------------------------
1 | # AutoInstall
2 | Android 无需Root实现APK的静默安装
3 |
--------------------------------------------------------------------------------
/assets/AidlServerDemo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smuyyh/AutoInstall/afc7cca5d18d13303a927bbd32dafd4cd9d4480f/assets/AidlServerDemo.apk
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-22
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smuyyh/AutoInstall/afc7cca5d18d13303a927bbd32dafd4cd9d4480f/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smuyyh/AutoInstall/afc7cca5d18d13303a927bbd32dafd4cd9d4480f/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smuyyh/AutoInstall/afc7cca5d18d13303a927bbd32dafd4cd9d4480f/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smuyyh/AutoInstall/afc7cca5d18d13303a927bbd32dafd4cd9d4480f/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | AutoInstall
5 | Hello world!
6 | Settings
7 |
8 |
9 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/android/annotation/SystemApi.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 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.annotation;
18 |
19 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
20 | import static java.lang.annotation.ElementType.CONSTRUCTOR;
21 | import static java.lang.annotation.ElementType.FIELD;
22 | import static java.lang.annotation.ElementType.METHOD;
23 | import static java.lang.annotation.ElementType.PACKAGE;
24 | import static java.lang.annotation.ElementType.TYPE;
25 |
26 | import java.lang.annotation.Retention;
27 | import java.lang.annotation.RetentionPolicy;
28 | import java.lang.annotation.Target;
29 |
30 | /**
31 | * Indicates an API is exposed for use by bundled system applications.
32 | *
33 | * These APIs are not guaranteed to remain consistent release-to-release,
34 | * and are not for use by apps linking against the Android SDK.
35 | *
36 | * This annotation should only appear on API that is already marked
@hide
.
37 | *
38 | *
39 | * @hide
40 | */
41 | @Target({TYPE, FIELD, METHOD, CONSTRUCTOR, ANNOTATION_TYPE, PACKAGE})
42 | @Retention(RetentionPolicy.SOURCE)
43 | public @interface SystemApi {
44 | }
45 |
--------------------------------------------------------------------------------
/src/android/content/pm/ContainerEncryptionParams.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012, 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 | parcelable ContainerEncryptionParams;
20 |
--------------------------------------------------------------------------------
/src/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 |
--------------------------------------------------------------------------------
/src/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 |
--------------------------------------------------------------------------------
/src/android/content/pm/IPackageDeleteObserver2.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 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 android.content.Intent;
20 |
21 | /** {@hide} */
22 | oneway interface IPackageDeleteObserver2 {
23 | void onUserActionRequired(in Intent intent);
24 | void onPackageDeleted(String packageName, int returnCode, String msg);
25 | }
26 |
--------------------------------------------------------------------------------
/src/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 |
--------------------------------------------------------------------------------
/src/android/content/pm/IPackageInstallObserver2.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 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 android.content.Intent;
20 | import android.os.Bundle;
21 |
22 | /**
23 | * API for installation callbacks from the Package Manager. In certain result cases
24 | * additional information will be provided.
25 | * @hide
26 | */
27 | oneway interface IPackageInstallObserver2 {
28 | void onUserActionRequired(in Intent intent);
29 |
30 | /**
31 | * The install operation has completed. {@code returnCode} holds a numeric code
32 | * indicating success or failure. In certain cases the {@code extras} Bundle will
33 | * contain additional details:
34 | *
35 | *
36 | *
37 | *
INSTALL_FAILED_DUPLICATE_PERMISSION
38 | *
Two strings are provided in the extras bundle: EXTRA_EXISTING_PERMISSION
39 | * is the name of the permission that the app is attempting to define, and
40 | * EXTRA_EXISTING_PACKAGE is the package name of the app which has already
41 | * defined the permission.
42 | *
43 | *
44 | */
45 | void onPackageInstalled(String basePackageName, int returnCode, String msg, in Bundle extras);
46 | }
47 |
--------------------------------------------------------------------------------
/src/android/content/pm/IPackageInstaller.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 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 android.content.pm.IPackageDeleteObserver2;
20 | import android.content.pm.IPackageInstallerCallback;
21 | import android.content.pm.IPackageInstallerSession;
22 | import android.content.pm.PackageInstaller;
23 | import android.content.pm.ParceledListSlice;
24 | import android.content.IntentSender;
25 |
26 | import android.graphics.Bitmap;
27 |
28 | /** {@hide} */
29 | interface IPackageInstaller {
30 | //int createSession(in PackageInstaller.SessionParams params, String installerPackageName, int userId);
31 |
32 | void updateSessionAppIcon(int sessionId, in Bitmap appIcon);
33 | void updateSessionAppLabel(int sessionId, String appLabel);
34 |
35 | void abandonSession(int sessionId);
36 |
37 | IPackageInstallerSession openSession(int sessionId);
38 |
39 | PackageInstaller.SessionInfo getSessionInfo(int sessionId);
40 |
41 | ParceledListSlice getAllSessions(int userId);
42 | ParceledListSlice getMySessions(String installerPackageName, int userId);
43 |
44 | void registerCallback(IPackageInstallerCallback callback, int userId);
45 | void unregisterCallback(IPackageInstallerCallback callback);
46 |
47 | void uninstall(String packageName, int flags, in IntentSender statusReceiver, int userId);
48 |
49 | void setPermissionsResult(int sessionId, boolean accepted);
50 | }
51 |
--------------------------------------------------------------------------------
/src/android/content/pm/IPackageInstallerCallback.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 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 | /** {@hide} */
20 | oneway interface IPackageInstallerCallback {
21 | void onSessionCreated(int sessionId);
22 | void onSessionBadgingChanged(int sessionId);
23 | void onSessionActiveChanged(int sessionId, boolean active);
24 | void onSessionProgressChanged(int sessionId, float progress);
25 | void onSessionFinished(int sessionId, boolean success);
26 | }
27 |
--------------------------------------------------------------------------------
/src/android/content/pm/IPackageInstallerSession.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 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 android.content.pm.IPackageInstallObserver2;
20 | import android.content.IntentSender;
21 | import android.os.ParcelFileDescriptor;
22 |
23 | /** {@hide} */
24 | interface IPackageInstallerSession {
25 | void setClientProgress(float progress);
26 | void addClientProgress(float progress);
27 |
28 | String[] getNames();
29 | ParcelFileDescriptor openWrite(String name, long offsetBytes, long lengthBytes);
30 | ParcelFileDescriptor openRead(String name);
31 |
32 | void close();
33 | void commit(in IntentSender statusReceiver);
34 | void abandon();
35 | }
36 |
--------------------------------------------------------------------------------
/src/android/content/pm/IPackageManager.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.ComponentName;
21 | import android.content.Intent;
22 | import android.content.IntentFilter;
23 | import android.content.pm.ActivityInfo;
24 | import android.content.pm.ApplicationInfo;
25 | import android.content.pm.ContainerEncryptionParams;
26 | import android.content.pm.FeatureInfo;
27 | import android.content.pm.IPackageInstallObserver2;
28 | import android.content.pm.IPackageInstaller;
29 | import android.content.pm.IPackageDeleteObserver;
30 | import android.content.pm.IPackageDeleteObserver2;
31 | import android.content.pm.IPackageDataObserver;
32 | import android.content.pm.IPackageMoveObserver;
33 | import android.content.pm.IPackageStatsObserver;
34 | import android.content.pm.InstrumentationInfo;
35 | import android.content.pm.KeySet;
36 | import android.content.pm.PackageInfo;
37 | import android.content.pm.ManifestDigest;
38 | import android.content.pm.PackageCleanItem;
39 | import android.content.pm.ParceledListSlice;
40 | import android.content.pm.ProviderInfo;
41 | import android.content.pm.PermissionGroupInfo;
42 | import android.content.pm.PermissionInfo;
43 | import android.content.pm.ResolveInfo;
44 | import android.content.pm.ServiceInfo;
45 | import android.content.pm.UserInfo;
46 | import android.content.pm.VerificationParams;
47 | import android.content.pm.VerifierDeviceIdentity;
48 | import android.net.Uri;
49 | import android.os.ParcelFileDescriptor;
50 | import android.content.IntentSender;
51 |
52 | /**
53 | * See {@link PackageManager} for documentation on most of the APIs
54 | * here.
55 | *
56 | * {@hide}
57 | */
58 | interface IPackageManager {
59 | boolean isPackageAvailable(String packageName, int userId);
60 | PackageInfo getPackageInfo(String packageName, int flags, int userId);
61 | int getPackageUid(String packageName, int userId);
62 | int[] getPackageGids(String packageName);
63 |
64 | String[] currentToCanonicalPackageNames(in String[] names);
65 | String[] canonicalToCurrentPackageNames(in String[] names);
66 |
67 | PermissionInfo getPermissionInfo(String name, int flags);
68 |
69 | List queryPermissionsByGroup(String group, int flags);
70 |
71 | PermissionGroupInfo getPermissionGroupInfo(String name, int flags);
72 |
73 | List getAllPermissionGroups(int flags);
74 |
75 | ApplicationInfo getApplicationInfo(String packageName, int flags ,int userId);
76 |
77 | ActivityInfo getActivityInfo(in ComponentName className, int flags, int userId);
78 |
79 | boolean activitySupportsIntent(in ComponentName className, in Intent intent,
80 | String resolvedType);
81 |
82 | ActivityInfo getReceiverInfo(in ComponentName className, int flags, int userId);
83 |
84 | ServiceInfo getServiceInfo(in ComponentName className, int flags, int userId);
85 |
86 | ProviderInfo getProviderInfo(in ComponentName className, int flags, int userId);
87 |
88 | int checkPermission(String permName, String pkgName);
89 |
90 | int checkUidPermission(String permName, int uid);
91 |
92 | boolean addPermission(in PermissionInfo info);
93 |
94 | void removePermission(String name);
95 |
96 | void grantPermission(String packageName, String permissionName);
97 |
98 | void revokePermission(String packageName, String permissionName);
99 |
100 | boolean isProtectedBroadcast(String actionName);
101 |
102 | int checkSignatures(String pkg1, String pkg2);
103 |
104 | int checkUidSignatures(int uid1, int uid2);
105 |
106 | String[] getPackagesForUid(int uid);
107 |
108 | String getNameForUid(int uid);
109 |
110 | int getUidForSharedUser(String sharedUserName);
111 |
112 | int getFlagsForUid(int uid);
113 |
114 | boolean isUidPrivileged(int uid);
115 |
116 | String[] getAppOpPermissionPackages(String permissionName);
117 |
118 | ResolveInfo resolveIntent(in Intent intent, String resolvedType, int flags, int userId);
119 |
120 | boolean canForwardTo(in Intent intent, String resolvedType, int sourceUserId, int targetUserId);
121 |
122 | List queryIntentActivities(in Intent intent,
123 | String resolvedType, int flags, int userId);
124 |
125 | List queryIntentActivityOptions(
126 | in ComponentName caller, in Intent[] specifics,
127 | in String[] specificTypes, in Intent intent,
128 | String resolvedType, int flags, int userId);
129 |
130 | List queryIntentReceivers(in Intent intent,
131 | String resolvedType, int flags, int userId);
132 |
133 | ResolveInfo resolveService(in Intent intent,
134 | String resolvedType, int flags, int userId);
135 |
136 | List queryIntentServices(in Intent intent,
137 | String resolvedType, int flags, int userId);
138 |
139 | List queryIntentContentProviders(in Intent intent,
140 | String resolvedType, int flags, int userId);
141 |
142 | /**
143 | * This implements getInstalledPackages via a "last returned row"
144 | * mechanism that is not exposed in the API. This is to get around the IPC
145 | * limit that kicks in when flags are included that bloat up the data
146 | * returned.
147 | */
148 | ParceledListSlice getInstalledPackages(int flags, in int userId);
149 |
150 | /**
151 | * This implements getPackagesHoldingPermissions via a "last returned row"
152 | * mechanism that is not exposed in the API. This is to get around the IPC
153 | * limit that kicks in when flags are included that bloat up the data
154 | * returned.
155 | */
156 | ParceledListSlice getPackagesHoldingPermissions(in String[] permissions,
157 | int flags, int userId);
158 |
159 | /**
160 | * This implements getInstalledApplications via a "last returned row"
161 | * mechanism that is not exposed in the API. This is to get around the IPC
162 | * limit that kicks in when flags are included that bloat up the data
163 | * returned.
164 | */
165 | ParceledListSlice getInstalledApplications(int flags, int userId);
166 |
167 | /**
168 | * Retrieve all applications that are marked as persistent.
169 | *
170 | * @return A List<applicationInfo> containing one entry for each persistent
171 | * application.
172 | */
173 | List getPersistentApplications(int flags);
174 |
175 | ProviderInfo resolveContentProvider(String name, int flags, int userId);
176 |
177 | /**
178 | * Retrieve sync information for all content providers.
179 | *
180 | * @param outNames Filled in with a list of the root names of the content
181 | * providers that can sync.
182 | * @param outInfo Filled in with a list of the ProviderInfo for each
183 | * name in 'outNames'.
184 | */
185 | void querySyncProviders(inout List outNames,
186 | inout List outInfo);
187 |
188 | List queryContentProviders(
189 | String processName, int uid, int flags);
190 |
191 | InstrumentationInfo getInstrumentationInfo(
192 | in ComponentName className, int flags);
193 |
194 | List queryInstrumentation(
195 | String targetPackage, int flags);
196 |
197 | void installPackage(in String originPath,
198 | in IPackageInstallObserver2 observer,
199 | int flags,
200 | in String installerPackageName,
201 | in VerificationParams verificationParams,
202 | in String packageAbiOverride);
203 |
204 | void installPackageAsUser(in String originPath,
205 | in IPackageInstallObserver2 observer,
206 | int flags,
207 | in String installerPackageName,
208 | in VerificationParams verificationParams,
209 | in String packageAbiOverride,
210 | int userId);
211 |
212 | void finishPackageInstall(int token);
213 |
214 | void setInstallerPackageName(in String targetPackage, in String installerPackageName);
215 |
216 | /** @deprecated rawr, don't call AIDL methods directly! */
217 | void deletePackageAsUser(in String packageName, IPackageDeleteObserver observer,
218 | int userId, int flags);
219 |
220 | /**
221 | * Delete a package for a specific user.
222 | *
223 | * @param packageName The fully qualified name of the package to delete.
224 | * @param observer a callback to use to notify when the package deletion in finished.
225 | * @param userId the id of the user for whom to delete the package
226 | * @param flags - possible values: {@link #DONT_DELETE_DATA}
227 | */
228 | void deletePackage(in String packageName, IPackageDeleteObserver2 observer, int userId, int flags);
229 |
230 | String getInstallerPackageName(in String packageName);
231 |
232 | void addPackageToPreferred(String packageName);
233 |
234 | void removePackageFromPreferred(String packageName);
235 |
236 | List getPreferredPackages(int flags);
237 |
238 | void resetPreferredActivities(int userId);
239 |
240 | ResolveInfo getLastChosenActivity(in Intent intent,
241 | String resolvedType, int flags);
242 |
243 | void setLastChosenActivity(in Intent intent, String resolvedType, int flags,
244 | in IntentFilter filter, int match, in ComponentName activity);
245 |
246 | void addPreferredActivity(in IntentFilter filter, int match,
247 | in ComponentName[] set, in ComponentName activity, int userId);
248 |
249 | void replacePreferredActivity(in IntentFilter filter, int match,
250 | in ComponentName[] set, in ComponentName activity, int userId);
251 |
252 | void clearPackagePreferredActivities(String packageName);
253 |
254 | int getPreferredActivities(out List outFilters,
255 | out List outActivities, String packageName);
256 |
257 | void addPersistentPreferredActivity(in IntentFilter filter, in ComponentName activity, int userId);
258 |
259 | void clearPackagePersistentPreferredActivities(String packageName, int userId);
260 |
261 | void addCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage,
262 | int ownerUserId, int sourceUserId, int targetUserId, int flags);
263 |
264 | void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage, int ownerUserId);
265 |
266 | /**
267 | * Report the set of 'Home' activity candidates, plus (if any) which of them
268 | * is the current "always use this one" setting.
269 | */
270 | ComponentName getHomeActivities(out List outHomeCandidates);
271 |
272 | /**
273 | * As per {@link android.content.pm.PackageManager#setComponentEnabledSetting}.
274 | */
275 | void setComponentEnabledSetting(in ComponentName componentName,
276 | in int newState, in int flags, int userId);
277 |
278 | /**
279 | * As per {@link android.content.pm.PackageManager#getComponentEnabledSetting}.
280 | */
281 | int getComponentEnabledSetting(in ComponentName componentName, int userId);
282 |
283 | /**
284 | * As per {@link android.content.pm.PackageManager#setApplicationEnabledSetting}.
285 | */
286 | void setApplicationEnabledSetting(in String packageName, in int newState, int flags,
287 | int userId, String callingPackage);
288 |
289 | /**
290 | * As per {@link android.content.pm.PackageManager#getApplicationEnabledSetting}.
291 | */
292 | int getApplicationEnabledSetting(in String packageName, int userId);
293 |
294 | /**
295 | * Set whether the given package should be considered stopped, making
296 | * it not visible to implicit intents that filter out stopped packages.
297 | */
298 | void setPackageStoppedState(String packageName, boolean stopped, int userId);
299 |
300 | /**
301 | * Free storage by deleting LRU sorted list of cache files across
302 | * all applications. If the currently available free storage
303 | * on the device is greater than or equal to the requested
304 | * free storage, no cache files are cleared. If the currently
305 | * available storage on the device is less than the requested
306 | * free storage, some or all of the cache files across
307 | * all applications are deleted (based on last accessed time)
308 | * to increase the free storage space on the device to
309 | * the requested value. There is no guarantee that clearing all
310 | * the cache files from all applications will clear up
311 | * enough storage to achieve the desired value.
312 | * @param freeStorageSize The number of bytes of storage to be
313 | * freed by the system. Say if freeStorageSize is XX,
314 | * and the current free storage is YY,
315 | * if XX is less than YY, just return. if not free XX-YY number
316 | * of bytes if possible.
317 | * @param observer call back used to notify when
318 | * the operation is completed
319 | */
320 | void freeStorageAndNotify(in long freeStorageSize,
321 | IPackageDataObserver observer);
322 |
323 | /**
324 | * Free storage by deleting LRU sorted list of cache files across
325 | * all applications. If the currently available free storage
326 | * on the device is greater than or equal to the requested
327 | * free storage, no cache files are cleared. If the currently
328 | * available storage on the device is less than the requested
329 | * free storage, some or all of the cache files across
330 | * all applications are deleted (based on last accessed time)
331 | * to increase the free storage space on the device to
332 | * the requested value. There is no guarantee that clearing all
333 | * the cache files from all applications will clear up
334 | * enough storage to achieve the desired value.
335 | * @param freeStorageSize The number of bytes of storage to be
336 | * freed by the system. Say if freeStorageSize is XX,
337 | * and the current free storage is YY,
338 | * if XX is less than YY, just return. if not free XX-YY number
339 | * of bytes if possible.
340 | * @param pi IntentSender call back used to
341 | * notify when the operation is completed.May be null
342 | * to indicate that no call back is desired.
343 | */
344 | void freeStorage(in long freeStorageSize,
345 | in IntentSender pi);
346 |
347 | /**
348 | * Delete all the cache files in an applications cache directory
349 | * @param packageName The package name of the application whose cache
350 | * files need to be deleted
351 | * @param observer a callback used to notify when the deletion is finished.
352 | */
353 | void deleteApplicationCacheFiles(in String packageName, IPackageDataObserver observer);
354 |
355 | /**
356 | * Clear the user data directory of an application.
357 | * @param packageName The package name of the application whose cache
358 | * files need to be deleted
359 | * @param observer a callback used to notify when the operation is completed.
360 | */
361 | void clearApplicationUserData(in String packageName, IPackageDataObserver observer, int userId);
362 |
363 | /**
364 | * Get package statistics including the code, data and cache size for
365 | * an already installed package
366 | * @param packageName The package name of the application
367 | * @param userHandle Which user the size should be retrieved for
368 | * @param observer a callback to use to notify when the asynchronous
369 | * retrieval of information is complete.
370 | */
371 | void getPackageSizeInfo(in String packageName, int userHandle, IPackageStatsObserver observer);
372 |
373 | /**
374 | * Get a list of shared libraries that are available on the
375 | * system.
376 | */
377 | String[] getSystemSharedLibraryNames();
378 |
379 | /**
380 | * Get a list of features that are available on the
381 | * system.
382 | */
383 | FeatureInfo[] getSystemAvailableFeatures();
384 |
385 | boolean hasSystemFeature(String name);
386 |
387 | void enterSafeMode();
388 | boolean isSafeMode();
389 | void systemReady();
390 | boolean hasSystemUidErrors();
391 |
392 | /**
393 | * Ask the package manager to perform boot-time dex-opt of all
394 | * existing packages.
395 | */
396 | void performBootDexOpt();
397 |
398 | /**
399 | * Ask the package manager to perform dex-opt (if needed) on the given
400 | * package and for the given instruction set if it already hasn't done
401 | * so.
402 | *
403 | * If the supplied instructionSet is null, the package manager will use
404 | * the packages default instruction set.
405 | *
406 | * In most cases, apps are dexopted in advance and this function will
407 | * be a no-op.
408 | */
409 | boolean performDexOptIfNeeded(String packageName, String instructionSet);
410 |
411 | void forceDexOpt(String packageName);
412 |
413 | /**
414 | * Update status of external media on the package manager to scan and
415 | * install packages installed on the external media. Like say the
416 | * MountService uses this to call into the package manager to update
417 | * status of sdcard.
418 | */
419 | void updateExternalMediaStatus(boolean mounted, boolean reportStatus);
420 |
421 | PackageCleanItem nextPackageToClean(in PackageCleanItem lastPackage);
422 |
423 | void movePackage(String packageName, IPackageMoveObserver observer, int flags);
424 |
425 | boolean addPermissionAsync(in PermissionInfo info);
426 |
427 | boolean setInstallLocation(int loc);
428 | int getInstallLocation();
429 |
430 | int installExistingPackageAsUser(String packageName, int userId);
431 |
432 | void verifyPendingInstall(int id, int verificationCode);
433 | void extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay);
434 |
435 | VerifierDeviceIdentity getVerifierDeviceIdentity();
436 |
437 | boolean isFirstBoot();
438 | boolean isOnlyCoreApps();
439 |
440 | void setPermissionEnforced(String permission, boolean enforced);
441 | boolean isPermissionEnforced(String permission);
442 |
443 | /** Reflects current DeviceStorageMonitorService state */
444 | boolean isStorageLow();
445 |
446 | boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, int userId);
447 | boolean getApplicationHiddenSettingAsUser(String packageName, int userId);
448 |
449 | IPackageInstaller getPackageInstaller();
450 |
451 | boolean setBlockUninstallForUser(String packageName, boolean blockUninstall, int userId);
452 | boolean getBlockUninstallForUser(String packageName, int userId);
453 |
454 | KeySet getKeySetByAlias(String packageName, String alias);
455 | KeySet getSigningKeySet(String packageName);
456 | boolean isPackageSignedByKeySet(String packageName, in KeySet ks);
457 | boolean isPackageSignedByKeySetExactly(String packageName, in KeySet ks);
458 | }
459 |
--------------------------------------------------------------------------------
/src/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 |
--------------------------------------------------------------------------------
/src/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 |
--------------------------------------------------------------------------------
/src/android/content/pm/KeySet.aidl:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014, 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 | parcelable KeySet;
--------------------------------------------------------------------------------
/src/android/content/pm/KeySet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 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 android.os.IBinder;
20 | import android.os.Parcel;
21 | import android.os.Parcelable;
22 |
23 | /**
24 | * Represents a {@code KeySet} that has been declared in the AndroidManifest.xml
25 | * file for the application. A {@code KeySet} can be used explicitly to
26 | * represent a trust relationship with other applications on the device.
27 | * @hide
28 | */
29 | public class KeySet implements Parcelable {
30 |
31 | private IBinder token;
32 |
33 | /** @hide */
34 | public KeySet(IBinder token) {
35 | if (token == null) {
36 | throw new NullPointerException("null value for KeySet IBinder token");
37 | }
38 | this.token = token;
39 | }
40 |
41 | /** @hide */
42 | public IBinder getToken() {
43 | return token;
44 | }
45 |
46 | /** @hide */
47 | @Override
48 | public boolean equals(Object o) {
49 | if (o instanceof KeySet) {
50 | KeySet ks = (KeySet) o;
51 | return token == ks.token;
52 | }
53 | return false;
54 | }
55 |
56 | /** @hide */
57 | @Override
58 | public int hashCode() {
59 | return token.hashCode();
60 | }
61 |
62 | /**
63 | * Implement Parcelable
64 | * @hide
65 | */
66 | public static final Parcelable.Creator CREATOR
67 | = new Parcelable.Creator() {
68 |
69 | /**
70 | * Create a KeySet from a Parcel
71 | *
72 | * @param in The parcel containing the KeySet
73 | */
74 | public KeySet createFromParcel(Parcel source) {
75 | return readFromParcel(source);
76 | }
77 |
78 | /**
79 | * Create an array of null KeySets
80 | */
81 | public KeySet[] newArray(int size) {
82 | return new KeySet[size];
83 | }
84 | };
85 |
86 | /**
87 | * @hide
88 | */
89 | private static KeySet readFromParcel(Parcel in) {
90 | IBinder token = in.readStrongBinder();
91 | return new KeySet(token);
92 | }
93 |
94 | /**
95 | * @hide
96 | */
97 | @Override
98 | public void writeToParcel(Parcel out, int flags) {
99 | out.writeStrongBinder(token);
100 | }
101 |
102 | /**
103 | * @hide
104 | */
105 | @Override
106 | public int describeContents() {
107 | return 0;
108 | }
109 | }
--------------------------------------------------------------------------------
/src/android/content/pm/ManifestDigest.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011, 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 | parcelable ManifestDigest;
20 |
--------------------------------------------------------------------------------
/src/android/content/pm/ManifestDigest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 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.io.BufferedInputStream;
20 | import java.io.IOException;
21 | import java.io.InputStream;
22 | import java.security.DigestInputStream;
23 | import java.security.MessageDigest;
24 | import java.security.NoSuchAlgorithmException;
25 | import java.util.Arrays;
26 |
27 | import android.annotation.SystemApi;
28 | import android.os.Parcel;
29 | import android.os.Parcelable;
30 | import android.util.Log;
31 |
32 | /**
33 | * Represents the manifest digest for a package. This is suitable for comparison
34 | * of two packages to know whether the manifests are identical.
35 | *
36 | * @hide
37 | */
38 | @SystemApi
39 | public class ManifestDigest implements Parcelable {
40 | private static final String TAG = "ManifestDigest";
41 |
42 | /**
43 | * The digits for every supported radix.
44 | */
45 | private static final char[] DIGITS = {
46 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
47 | 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
48 | 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
49 | 'u', 'v', 'w', 'x', 'y', 'z'
50 | };
51 |
52 | private static final char[] UPPER_CASE_DIGITS = {
53 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
54 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
55 | 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
56 | 'U', 'V', 'W', 'X', 'Y', 'Z'
57 | };
58 |
59 | /** The digest of the manifest in our preferred order. */
60 | private final byte[] mDigest;
61 |
62 | /** What we print out first when toString() is called. */
63 | private static final String TO_STRING_PREFIX = "ManifestDigest {mDigest=";
64 |
65 | /** Digest algorithm to use. */
66 | private static final String DIGEST_ALGORITHM = "SHA-256";
67 |
68 | ManifestDigest(byte[] digest) {
69 | mDigest = digest;
70 | }
71 |
72 | private ManifestDigest(Parcel source) {
73 | mDigest = source.createByteArray();
74 | }
75 |
76 | static ManifestDigest fromInputStream(InputStream fileIs) {
77 | if (fileIs == null) {
78 | return null;
79 | }
80 |
81 | final MessageDigest md;
82 | try {
83 | md = MessageDigest.getInstance(DIGEST_ALGORITHM);
84 | } catch (NoSuchAlgorithmException e) {
85 | throw new RuntimeException(DIGEST_ALGORITHM + " must be available", e);
86 | }
87 |
88 | final DigestInputStream dis = new DigestInputStream(new BufferedInputStream(fileIs), md);
89 | try {
90 | byte[] readBuffer = new byte[8192];
91 | while (dis.read(readBuffer, 0, readBuffer.length) != -1) {
92 | // not using
93 | }
94 | } catch (IOException e) {
95 | Log.w(TAG, "Could not read manifest");
96 | return null;
97 | } finally {
98 | try {
99 | if(dis!=null )
100 | dis.close();
101 | } catch (IOException e) {
102 | // TODO Auto-generated catch block
103 | e.printStackTrace();
104 | }
105 | }
106 |
107 | final byte[] digest = md.digest();
108 | return new ManifestDigest(digest);
109 | }
110 |
111 | @Override
112 | public int describeContents() {
113 | return 0;
114 | }
115 |
116 | @Override
117 | public boolean equals(Object o) {
118 | if (!(o instanceof ManifestDigest)) {
119 | return false;
120 | }
121 |
122 | final ManifestDigest other = (ManifestDigest) o;
123 |
124 | return this == other || Arrays.equals(mDigest, other.mDigest);
125 | }
126 |
127 | @Override
128 | public int hashCode() {
129 | return Arrays.hashCode(mDigest);
130 | }
131 |
132 | @Override
133 | public String toString() {
134 | final StringBuilder sb = new StringBuilder(TO_STRING_PREFIX.length()
135 | + (mDigest.length * 3) + 1);
136 |
137 | sb.append(TO_STRING_PREFIX);
138 |
139 | final int N = mDigest.length;
140 | for (int i = 0; i < N; i++) {
141 | final byte b = mDigest[i];
142 | appendByteAsHex(sb, b, false);
143 | sb.append(',');
144 | }
145 | sb.append('}');
146 |
147 | return sb.toString();
148 | }
149 |
150 | public static StringBuilder appendByteAsHex(StringBuilder sb, byte b, boolean upperCase) {
151 | char[] digits = upperCase ? UPPER_CASE_DIGITS : DIGITS;
152 | sb.append(digits[(b >> 4) & 0xf]);
153 | sb.append(digits[b & 0xf]);
154 | return sb;
155 | }
156 |
157 | @Override
158 | public void writeToParcel(Parcel dest, int flags) {
159 | dest.writeByteArray(mDigest);
160 | }
161 |
162 | public static final Parcelable.Creator CREATOR
163 | = new Parcelable.Creator() {
164 | public ManifestDigest createFromParcel(Parcel source) {
165 | return new ManifestDigest(source);
166 | }
167 |
168 | public ManifestDigest[] newArray(int size) {
169 | return new ManifestDigest[size];
170 | }
171 | };
172 |
173 | }
--------------------------------------------------------------------------------
/src/android/content/pm/PackageCleanItem.aidl:
--------------------------------------------------------------------------------
1 | /* Copyright 2012, The Android Open Source Project
2 | **
3 | ** Licensed under the Apache License, Version 2.0 (the "License");
4 | ** you may not use this file except in compliance with the License.
5 | ** You may obtain a copy of the License at
6 | **
7 | ** http://www.apache.org/licenses/LICENSE-2.0
8 | **
9 | ** Unless required by applicable law or agreed to in writing, software
10 | ** distributed under the License is distributed on an "AS IS" BASIS,
11 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | ** See the License for the specific language governing permissions and
13 | ** limitations under the License.
14 | */
15 |
16 | package android.content.pm;
17 |
18 | parcelable PackageCleanItem;
19 |
--------------------------------------------------------------------------------
/src/android/content/pm/PackageCleanItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 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 android.os.Parcel;
20 | import android.os.Parcelable;
21 |
22 | /** @hide */
23 | public class PackageCleanItem {
24 | public final int userId;
25 | public final String packageName;
26 | public final boolean andCode;
27 |
28 | public PackageCleanItem(int userId, String packageName, boolean andCode) {
29 | this.userId = userId;
30 | this.packageName = packageName;
31 | this.andCode = andCode;
32 | }
33 |
34 | @Override
35 | public boolean equals(Object obj) {
36 | if (this == obj) {
37 | return true;
38 | }
39 | try {
40 | if (obj != null) {
41 | PackageCleanItem other = (PackageCleanItem)obj;
42 | return userId == other.userId && packageName.equals(other.packageName)
43 | && andCode == other.andCode;
44 | }
45 | } catch (ClassCastException e) {
46 | }
47 | return false;
48 | }
49 |
50 | @Override
51 | public int hashCode() {
52 | int result = 17;
53 | result = 31 * result + userId;
54 | result = 31 * result + packageName.hashCode();
55 | result = 31 * result + (andCode ? 1 : 0);
56 | return result;
57 | }
58 |
59 | public int describeContents() {
60 | return 0;
61 | }
62 |
63 | public void writeToParcel(Parcel dest, int parcelableFlags) {
64 | dest.writeInt(userId);
65 | dest.writeString(packageName);
66 | dest.writeInt(andCode ? 1 : 0);
67 | }
68 |
69 | public static final Parcelable.Creator CREATOR
70 | = new Parcelable.Creator() {
71 | public PackageCleanItem createFromParcel(Parcel source) {
72 | return new PackageCleanItem(source);
73 | }
74 |
75 | public PackageCleanItem[] newArray(int size) {
76 | return new PackageCleanItem[size];
77 | }
78 | };
79 |
80 | private PackageCleanItem(Parcel source) {
81 | userId = source.readInt();
82 | packageName = source.readString();
83 | andCode = source.readInt() != 0;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/android/content/pm/PackageInstaller.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 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 | parcelable PackageInstaller.SessionParams;
20 | parcelable PackageInstaller.SessionInfo;
21 |
--------------------------------------------------------------------------------
/src/android/content/pm/ParceledListSlice.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011, 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 | parcelable ParceledListSlice;
20 |
--------------------------------------------------------------------------------
/src/android/content/pm/ParceledListSlice.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 android.os.Binder;
20 | import android.os.IBinder;
21 | import android.os.Parcel;
22 | import android.os.Parcelable;
23 | import android.os.RemoteException;
24 | import android.util.Log;
25 |
26 | import java.util.ArrayList;
27 | import java.util.List;
28 |
29 | /**
30 | * Transfer a large list of Parcelable objects across an IPC. Splits into
31 | * multiple transactions if needed.
32 | *
33 | * @hide
34 | */
35 | public class ParceledListSlice implements Parcelable {
36 | private static String TAG = "ParceledListSlice";
37 | private static boolean DEBUG = false;
38 |
39 | /*
40 | * TODO get this number from somewhere else. For now set it to a quarter of
41 | * the 1MB limit.
42 | */
43 | private static final int MAX_IPC_SIZE = 256 * 1024;
44 | private static final int MAX_FIRST_IPC_SIZE = MAX_IPC_SIZE / 2;
45 |
46 | private final List mList;
47 |
48 | public ParceledListSlice(List list) {
49 | mList = list;
50 | }
51 |
52 | private ParceledListSlice(Parcel p, ClassLoader loader) {
53 | final int N = p.readInt();
54 | mList = new ArrayList(N);
55 | if (DEBUG) Log.d(TAG, "Retrieving " + N + " items");
56 | if (N <= 0) {
57 | return;
58 | }
59 | Parcelable.Creator creator = p.readParcelable(loader);
60 | int i = 0;
61 | while (i < N) {
62 | if (p.readInt() == 0) {
63 | break;
64 | }
65 | //mList.add(p.readCreator(creator, loader));
66 | if (DEBUG) Log.d(TAG, "Read inline #" + i + ": " + mList.get(mList.size()-1));
67 | i++;
68 | }
69 | if (i >= N) {
70 | return;
71 | }
72 | final IBinder retriever = p.readStrongBinder();
73 | while (i < N) {
74 | if (DEBUG) Log.d(TAG, "Reading more @" + i + " of " + N + ": retriever=" + retriever);
75 | Parcel data = Parcel.obtain();
76 | Parcel reply = Parcel.obtain();
77 | data.writeInt(i);
78 | try {
79 | retriever.transact(IBinder.FIRST_CALL_TRANSACTION, data, reply, 0);
80 | } catch (RemoteException e) {
81 | Log.w(TAG, "Failure retrieving array; only received " + i + " of " + N, e);
82 | return;
83 | }
84 | while (i < N && reply.readInt() != 0) {
85 | //mList.add(reply.readCreator(creator, loader));
86 | if (DEBUG) Log.d(TAG, "Read extra #" + i + ": " + mList.get(mList.size()-1));
87 | i++;
88 | }
89 | reply.recycle();
90 | data.recycle();
91 | }
92 | }
93 |
94 | public List getList() {
95 | return mList;
96 | }
97 |
98 | @Override
99 | public int describeContents() {
100 | int contents = 0;
101 | for (int i=0; i 0) {
119 | //dest.writeParcelableCreator(mList.get(0));
120 | int i = 0;
121 | while (i < N && dest.dataSize() < MAX_FIRST_IPC_SIZE) {
122 | dest.writeInt(1);
123 | mList.get(i).writeToParcel(dest, callFlags);
124 | if (DEBUG) Log.d(TAG, "Wrote inline #" + i + ": " + mList.get(i));
125 | i++;
126 | }
127 | if (i < N) {
128 | dest.writeInt(0);
129 | Binder retriever = new Binder() {
130 | @Override
131 | protected boolean onTransact(int code, Parcel data, Parcel reply, int flags)
132 | throws RemoteException {
133 | if (code != FIRST_CALL_TRANSACTION) {
134 | return super.onTransact(code, data, reply, flags);
135 | }
136 | int i = data.readInt();
137 | if (DEBUG) Log.d(TAG, "Writing more @" + i + " of " + N);
138 | while (i < N && reply.dataSize() < MAX_IPC_SIZE) {
139 | reply.writeInt(1);
140 | mList.get(i).writeToParcel(reply, callFlags);
141 | if (DEBUG) Log.d(TAG, "Wrote extra #" + i + ": " + mList.get(i));
142 | i++;
143 | }
144 | if (i < N) {
145 | if (DEBUG) Log.d(TAG, "Breaking @" + i + " of " + N);
146 | reply.writeInt(0);
147 | }
148 | return true;
149 | }
150 | };
151 | if (DEBUG) Log.d(TAG, "Breaking @" + i + " of " + N + ": retriever=" + retriever);
152 | dest.writeStrongBinder(retriever);
153 | }
154 | }
155 | }
156 |
157 | @SuppressWarnings("unchecked")
158 | public static final Parcelable.ClassLoaderCreator CREATOR =
159 | new Parcelable.ClassLoaderCreator() {
160 | public ParceledListSlice createFromParcel(Parcel in) {
161 | return new ParceledListSlice(in, null);
162 | }
163 |
164 | @Override
165 | public ParceledListSlice createFromParcel(Parcel in, ClassLoader loader) {
166 | return new ParceledListSlice(in, loader);
167 | }
168 |
169 | public ParceledListSlice[] newArray(int size) {
170 | return new ParceledListSlice[size];
171 | }
172 | };
173 | }
174 |
--------------------------------------------------------------------------------
/src/android/content/pm/UserInfo.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | **
3 | ** Copyright 2011, 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 UserInfo;
21 |
--------------------------------------------------------------------------------
/src/android/content/pm/VerificationParams.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012, 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 | parcelable VerificationParams;
20 |
--------------------------------------------------------------------------------
/src/android/content/pm/VerificationParams.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 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 android.content.pm.ManifestDigest;
20 | import android.net.Uri;
21 | import android.os.Parcel;
22 | import android.os.Parcelable;
23 |
24 | /**
25 | * Represents verification parameters used to verify packages to be installed.
26 | *
27 | * @deprecated callers should migrate to {@link PackageInstaller}.
28 | * @hide
29 | */
30 | @Deprecated
31 | public class VerificationParams implements Parcelable {
32 | /** A constant used to indicate that a uid value is not present. */
33 | public static final int NO_UID = -1;
34 |
35 | /** What we print out first when toString() is called. */
36 | private static final String TO_STRING_PREFIX = "VerificationParams{";
37 |
38 | /** The location of the supplementary verification file. */
39 | private final Uri mVerificationURI;
40 |
41 | /** URI referencing where the package was downloaded from. */
42 | private final Uri mOriginatingURI;
43 |
44 | /** HTTP referrer URI associated with the originatingURI. */
45 | private final Uri mReferrer;
46 |
47 | /** UID of the application that the install request originated from. */
48 | private final int mOriginatingUid;
49 |
50 | /** UID of application requesting the install */
51 | private int mInstallerUid;
52 |
53 | /**
54 | * An object that holds the digest of the package which can be used to
55 | * verify ownership.
56 | */
57 | private final ManifestDigest mManifestDigest;
58 |
59 | /**
60 | * Creates verification specifications for installing with application verification.
61 | *
62 | * @param verificationURI The location of the supplementary verification
63 | * file. This can be a 'file:' or a 'content:' URI. May be {@code null}.
64 | * @param originatingURI URI referencing where the package was downloaded
65 | * from. May be {@code null}.
66 | * @param referrer HTTP referrer URI associated with the originatingURI.
67 | * May be {@code null}.
68 | * @param originatingUid UID of the application that the install request originated
69 | * from, or NO_UID if not present
70 | * @param manifestDigest an object that holds the digest of the package
71 | * which can be used to verify ownership. May be {@code null}.
72 | */
73 | public VerificationParams(Uri verificationURI, Uri originatingURI, Uri referrer,
74 | int originatingUid, ManifestDigest manifestDigest) {
75 | mVerificationURI = verificationURI;
76 | mOriginatingURI = originatingURI;
77 | mReferrer = referrer;
78 | mOriginatingUid = originatingUid;
79 | mManifestDigest = manifestDigest;
80 | mInstallerUid = NO_UID;
81 | }
82 |
83 | public Uri getVerificationURI() {
84 | return mVerificationURI;
85 | }
86 |
87 | public Uri getOriginatingURI() {
88 | return mOriginatingURI;
89 | }
90 |
91 | public Uri getReferrer() {
92 | return mReferrer;
93 | }
94 |
95 | /** return NO_UID if not available */
96 | public int getOriginatingUid() {
97 | return mOriginatingUid;
98 | }
99 |
100 | public ManifestDigest getManifestDigest() {
101 | return mManifestDigest;
102 | }
103 |
104 | /** @return NO_UID when not set */
105 | public int getInstallerUid() {
106 | return mInstallerUid;
107 | }
108 |
109 | public void setInstallerUid(int uid) {
110 | mInstallerUid = uid;
111 | }
112 |
113 | @Override
114 | public int describeContents() {
115 | return 0;
116 | }
117 |
118 | @Override
119 | public boolean equals(Object o) {
120 | if (this == o) {
121 | return true;
122 | }
123 |
124 | if (!(o instanceof VerificationParams)) {
125 | return false;
126 | }
127 |
128 | final VerificationParams other = (VerificationParams) o;
129 |
130 | if (mVerificationURI == null) {
131 | if (other.mVerificationURI != null) {
132 | return false;
133 | }
134 | } else if (!mVerificationURI.equals(other.mVerificationURI)) {
135 | return false;
136 | }
137 |
138 | if (mOriginatingURI == null) {
139 | if (other.mOriginatingURI != null) {
140 | return false;
141 | }
142 | } else if (!mOriginatingURI.equals(other.mOriginatingURI)) {
143 | return false;
144 | }
145 |
146 | if (mReferrer == null) {
147 | if (other.mReferrer != null) {
148 | return false;
149 | }
150 | } else if (!mReferrer.equals(other.mReferrer)) {
151 | return false;
152 | }
153 |
154 | if (mOriginatingUid != other.mOriginatingUid) {
155 | return false;
156 | }
157 |
158 | if (mManifestDigest == null) {
159 | if (other.mManifestDigest != null) {
160 | return false;
161 | }
162 | } else if (!mManifestDigest.equals(other.mManifestDigest)) {
163 | return false;
164 | }
165 |
166 | if (mInstallerUid != other.mInstallerUid) {
167 | return false;
168 | }
169 |
170 | return true;
171 | }
172 |
173 | @Override
174 | public int hashCode() {
175 | int hash = 3;
176 |
177 | hash += 5 * (mVerificationURI == null ? 1 : mVerificationURI.hashCode());
178 | hash += 7 * (mOriginatingURI == null ? 1 : mOriginatingURI.hashCode());
179 | hash += 11 * (mReferrer == null ? 1 : mReferrer.hashCode());
180 | hash += 13 * mOriginatingUid;
181 | hash += 17 * (mManifestDigest == null ? 1 : mManifestDigest.hashCode());
182 | hash += 19 * mInstallerUid;
183 |
184 | return hash;
185 | }
186 |
187 | @Override
188 | public String toString() {
189 | final StringBuilder sb = new StringBuilder(TO_STRING_PREFIX);
190 |
191 | sb.append("mVerificationURI=");
192 | sb.append(mVerificationURI.toString());
193 | sb.append(",mOriginatingURI=");
194 | sb.append(mOriginatingURI.toString());
195 | sb.append(",mReferrer=");
196 | sb.append(mReferrer.toString());
197 | sb.append(",mOriginatingUid=");
198 | sb.append(mOriginatingUid);
199 | sb.append(",mManifestDigest=");
200 | sb.append(mManifestDigest.toString());
201 | sb.append(",mInstallerUid=");
202 | sb.append(mInstallerUid);
203 | sb.append('}');
204 |
205 | return sb.toString();
206 | }
207 |
208 | @Override
209 | public void writeToParcel(Parcel dest, int flags) {
210 | dest.writeParcelable(mVerificationURI, 0);
211 | dest.writeParcelable(mOriginatingURI, 0);
212 | dest.writeParcelable(mReferrer, 0);
213 | dest.writeInt(mOriginatingUid);
214 | dest.writeParcelable(mManifestDigest, 0);
215 | dest.writeInt(mInstallerUid);
216 | }
217 |
218 |
219 | private VerificationParams(Parcel source) {
220 | mVerificationURI = source.readParcelable(Uri.class.getClassLoader());
221 | mOriginatingURI = source.readParcelable(Uri.class.getClassLoader());
222 | mReferrer = source.readParcelable(Uri.class.getClassLoader());
223 | mOriginatingUid = source.readInt();
224 | mManifestDigest = source.readParcelable(ManifestDigest.class.getClassLoader());
225 | mInstallerUid = source.readInt();
226 | }
227 |
228 | public static final Parcelable.Creator CREATOR =
229 | new Parcelable.Creator() {
230 | public VerificationParams createFromParcel(Parcel source) {
231 | return new VerificationParams(source);
232 | }
233 |
234 | public VerificationParams[] newArray(int size) {
235 | return new VerificationParams[size];
236 | }
237 | };
238 | }
239 |
--------------------------------------------------------------------------------
/src/android/content/pm/VerifierDeviceIdentity.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011, 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 | parcelable VerifierDeviceIdentity;
20 |
--------------------------------------------------------------------------------
/src/android/content/pm/VerifierDeviceIdentity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 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 android.os.Parcel;
20 | import android.os.Parcelable;
21 |
22 | import java.io.UnsupportedEncodingException;
23 | import java.security.SecureRandom;
24 | import java.util.Random;
25 |
26 | /**
27 | * An identity that uniquely identifies a particular device. In this
28 | * implementation, the identity is represented as a 64-bit integer encoded to a
29 | * 13-character string using RFC 4648's Base32 encoding without the trailing
30 | * padding. This makes it easy for users to read and write the code without
31 | * confusing 'I' (letter) with '1' (one) or 'O' (letter) with '0' (zero).
32 | *
33 | * @hide
34 | */
35 | public class VerifierDeviceIdentity implements Parcelable {
36 | /**
37 | * Encoded size of a long (64-bit) into Base32. This format will end up
38 | * looking like XXXX-XXXX-XXXX-X (length ignores hyphens) when applied with
39 | * the GROUP_SIZE below.
40 | */
41 | private static final int LONG_SIZE = 13;
42 |
43 | /**
44 | * Size of groupings when outputting as strings. This helps people read it
45 | * out and keep track of where they are.
46 | */
47 | private static final int GROUP_SIZE = 4;
48 |
49 | private final long mIdentity;
50 |
51 | private final String mIdentityString;
52 |
53 | /**
54 | * Create a verifier device identity from a long.
55 | *
56 | * @param identity device identity in a 64-bit integer.
57 | * @throws
58 | */
59 | public VerifierDeviceIdentity(long identity) {
60 | mIdentity = identity;
61 | mIdentityString = encodeBase32(identity);
62 | }
63 |
64 | private VerifierDeviceIdentity(Parcel source) {
65 | final long identity = source.readLong();
66 |
67 | mIdentity = identity;
68 | mIdentityString = encodeBase32(identity);
69 | }
70 |
71 | /**
72 | * Generate a new device identity.
73 | *
74 | * @return random uniformly-distributed device identity
75 | */
76 | public static VerifierDeviceIdentity generate() {
77 | final SecureRandom sr = new SecureRandom();
78 | return generate(sr);
79 | }
80 |
81 | /**
82 | * Generate a new device identity using a provided random number generator
83 | * class. This is used for testing.
84 | *
85 | * @param rng random number generator to retrieve the next long from
86 | * @return verifier device identity based on the input from the provided
87 | * random number generator
88 | */
89 | static VerifierDeviceIdentity generate(Random rng) {
90 | long identity = rng.nextLong();
91 | return new VerifierDeviceIdentity(identity);
92 | }
93 |
94 | private static final char ENCODE[] = {
95 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
96 | 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
97 | 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
98 | 'Y', 'Z', '2', '3', '4', '5', '6', '7',
99 | };
100 |
101 | private static final char SEPARATOR = '-';
102 |
103 | private static final String encodeBase32(long input) {
104 | final char[] alphabet = ENCODE;
105 |
106 | /*
107 | * Make a character array with room for the separators between each
108 | * group.
109 | */
110 | final char encoded[] = new char[LONG_SIZE + (LONG_SIZE / GROUP_SIZE)];
111 |
112 | int index = encoded.length;
113 | for (int i = 0; i < LONG_SIZE; i++) {
114 | /*
115 | * Make sure we don't put a separator at the beginning. Since we're
116 | * building from the rear of the array, we use (LONG_SIZE %
117 | * GROUP_SIZE) to make the odd-size group appear at the end instead
118 | * of the beginning.
119 | */
120 | if (i > 0 && (i % GROUP_SIZE) == (LONG_SIZE % GROUP_SIZE)) {
121 | encoded[--index] = SEPARATOR;
122 | }
123 |
124 | /*
125 | * Extract 5 bits of data, then shift it out.
126 | */
127 | final int group = (int) (input & 0x1F);
128 | input >>>= 5;
129 |
130 | encoded[--index] = alphabet[group];
131 | }
132 |
133 | return String.valueOf(encoded);
134 | }
135 |
136 | // TODO move this out to its own class (android.util.Base32)
137 | private static final long decodeBase32(byte[] input) throws IllegalArgumentException {
138 | long output = 0L;
139 | int numParsed = 0;
140 |
141 | final int N = input.length;
142 | for (int i = 0; i < N; i++) {
143 | final int group = input[i];
144 |
145 | /*
146 | * This essentially does the reverse of the ENCODED alphabet above
147 | * without a table. A..Z are 0..25 and 2..7 are 26..31.
148 | */
149 | final int value;
150 | if ('A' <= group && group <= 'Z') {
151 | value = group - 'A';
152 | } else if ('2' <= group && group <= '7') {
153 | value = group - ('2' - 26);
154 | } else if (group == SEPARATOR) {
155 | continue;
156 | } else if ('a' <= group && group <= 'z') {
157 | /* Lowercase letters should be the same as uppercase for Base32 */
158 | value = group - 'a';
159 | } else if (group == '0') {
160 | /* Be nice to users that mistake O (letter) for 0 (zero) */
161 | value = 'O' - 'A';
162 | } else if (group == '1') {
163 | /* Be nice to users that mistake I (letter) for 1 (one) */
164 | value = 'I' - 'A';
165 | } else {
166 | throw new IllegalArgumentException("base base-32 character: " + group);
167 | }
168 |
169 | output = (output << 5) | value;
170 | numParsed++;
171 |
172 | if (numParsed == 1) {
173 | if ((value & 0xF) != value) {
174 | throw new IllegalArgumentException("illegal start character; will overflow");
175 | }
176 | } else if (numParsed > 13) {
177 | throw new IllegalArgumentException("too long; should have 13 characters");
178 | }
179 | }
180 |
181 | if (numParsed != 13) {
182 | throw new IllegalArgumentException("too short; should have 13 characters");
183 | }
184 |
185 | return output;
186 | }
187 |
188 | @Override
189 | public int hashCode() {
190 | return (int) mIdentity;
191 | }
192 |
193 | @Override
194 | public boolean equals(Object other) {
195 | if (!(other instanceof VerifierDeviceIdentity)) {
196 | return false;
197 | }
198 |
199 | final VerifierDeviceIdentity o = (VerifierDeviceIdentity) other;
200 | return mIdentity == o.mIdentity;
201 | }
202 |
203 | @Override
204 | public String toString() {
205 | return mIdentityString;
206 | }
207 |
208 | public static VerifierDeviceIdentity parse(String deviceIdentity)
209 | throws IllegalArgumentException {
210 | final byte[] input;
211 | try {
212 | input = deviceIdentity.getBytes("US-ASCII");
213 | } catch (UnsupportedEncodingException e) {
214 | throw new IllegalArgumentException("bad base-32 characters in input");
215 | }
216 |
217 | return new VerifierDeviceIdentity(decodeBase32(input));
218 | }
219 |
220 | @Override
221 | public int describeContents() {
222 | return 0;
223 | }
224 |
225 | @Override
226 | public void writeToParcel(Parcel dest, int flags) {
227 | dest.writeLong(mIdentity);
228 | }
229 |
230 | public static final Parcelable.Creator CREATOR
231 | = new Parcelable.Creator() {
232 | public VerifierDeviceIdentity createFromParcel(Parcel source) {
233 | return new VerifierDeviceIdentity(source);
234 | }
235 |
236 | public VerifierDeviceIdentity[] newArray(int size) {
237 | return new VerifierDeviceIdentity[size];
238 | }
239 | };
240 | }
241 |
--------------------------------------------------------------------------------
/src/com/example/autoinstall/FileUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.autoinstall;
2 |
3 | import android.content.Context;
4 | import android.os.Environment;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 |
9 | /**
10 | * Created by yuyh on 2015/11/4.
11 | */
12 | public class FileUtils {
13 |
14 | /**
15 | * 检查SD卡是否存在
16 | *
17 | * @return 存在返回true,否则返回false
18 | */
19 | public static boolean isSdcardReady() {
20 | boolean sdCardExist = Environment.getExternalStorageState().equals(
21 | android.os.Environment.MEDIA_MOUNTED);
22 | return sdCardExist;
23 | }
24 |
25 | /**
26 | * 获得SD路径
27 | *
28 | * @return
29 | */
30 | public static String getSdcardPath() {
31 | return Environment.getExternalStorageDirectory().toString() + File.separator;
32 | }
33 |
34 | /**
35 | * 获取缓存路径
36 | *
37 | * @param context
38 | * @return
39 | */
40 | public static String getCachePath(Context context) {
41 | File cacheDir = context.getCacheDir();//文件所在目录为getFilesDir();
42 | return cacheDir.getPath() + File.separator;
43 | }
44 |
45 | /**
46 | * 根据文件路径 递归创建文件
47 | *
48 | * @param file
49 | */
50 | public static void createDipPath(String file) {
51 | String parentFile = file.substring(0, file.lastIndexOf("/"));
52 | File file1 = new File(file);
53 | File parent = new File(parentFile);
54 | if (!file1.exists()) {
55 | parent.mkdirs();
56 | try {
57 | file1.createNewFile();
58 | } catch (IOException e) {
59 | e.printStackTrace();
60 | }
61 | }
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/com/example/autoinstall/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.autoinstall;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.io.OutputStream;
8 | import java.lang.reflect.Method;
9 |
10 | import android.app.Activity;
11 | import android.content.Intent;
12 | import android.content.pm.IPackageInstallObserver2;
13 | import android.content.pm.IPackageManager;
14 | import android.content.pm.VerificationParams;
15 | import android.net.Uri;
16 | import android.os.Bundle;
17 | import android.os.IBinder;
18 | import android.os.RemoteException;
19 | import android.view.View;
20 |
21 | public class MainActivity extends Activity {
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_main);
27 | }
28 |
29 | /**
30 | * Button点击事件
31 | * @param view
32 | */
33 | public void install(View view)
34 | {
35 | String path = "";
36 | if (FileUtils.isSdcardReady()) {
37 | path = FileUtils.getSdcardPath();
38 | } else {
39 | path = FileUtils.getCachePath(this);
40 | }
41 | String fileName = path + "/AidlServerDemo.apk";
42 | File file = new File(fileName);
43 |
44 | try {
45 | if(!file.exists())
46 | copyAPK2SD(fileName);
47 | Uri uri = Uri.fromFile(new File(fileName));
48 | Class> clazz = Class.forName("android.os.ServiceManager");
49 | Method method = clazz.getMethod("getService", String.class);
50 | IBinder iBinder = (IBinder) method.invoke(null, "package");
51 | IPackageManager ipm = IPackageManager.Stub.asInterface(iBinder);
52 | @SuppressWarnings("deprecation")
53 | VerificationParams verificationParams = new VerificationParams(null, null, null, VerificationParams.NO_UID, null);
54 |
55 | ipm.installPackage(fileName, new PackageInstallObserver(), 2, null, verificationParams, "");
56 | } catch (Exception e) {
57 | // TODO Auto-generated catch block
58 | e.printStackTrace();
59 | }
60 |
61 | }
62 |
63 | // 用于显示结果
64 | class PackageInstallObserver extends IPackageInstallObserver2.Stub {
65 |
66 | @Override
67 | public void onUserActionRequired(Intent intent) throws RemoteException {
68 | // TODO Auto-generated method stub
69 |
70 | }
71 |
72 | @Override
73 | public void onPackageInstalled(String basePackageName, int returnCode, String msg, Bundle extras) throws RemoteException {
74 | // TODO Auto-generated method stub
75 |
76 | }
77 | };
78 |
79 | /**
80 | * 拷贝assets文件夹的APK插件到SD
81 | *
82 | * @param strOutFileName
83 | * @throws IOException
84 | */
85 | private void copyAPK2SD(String strOutFileName) throws IOException {
86 | FileUtils.createDipPath(strOutFileName);
87 | InputStream myInput = this.getAssets().open("AidlServerDemo.apk");
88 | OutputStream myOutput = new FileOutputStream(strOutFileName);
89 | byte[] buffer = new byte[1024];
90 | int length = myInput.read(buffer);
91 | while (length > 0) {
92 | myOutput.write(buffer, 0, length);
93 | length = myInput.read(buffer);
94 | }
95 | myOutput.flush();
96 | myInput.close();
97 | myOutput.close();
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/系统签名/AutoInstall.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smuyyh/AutoInstall/afc7cca5d18d13303a927bbd32dafd4cd9d4480f/系统签名/AutoInstall.apk
--------------------------------------------------------------------------------
/系统签名/AutoInstall_new.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smuyyh/AutoInstall/afc7cca5d18d13303a927bbd32dafd4cd9d4480f/系统签名/AutoInstall_new.apk
--------------------------------------------------------------------------------
/系统签名/SignApk.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smuyyh/AutoInstall/afc7cca5d18d13303a927bbd32dafd4cd9d4480f/系统签名/SignApk.jar
--------------------------------------------------------------------------------
/系统签名/platform.pk8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smuyyh/AutoInstall/afc7cca5d18d13303a927bbd32dafd4cd9d4480f/系统签名/platform.pk8
--------------------------------------------------------------------------------
/系统签名/platform.x509.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIEqDCCA5CgAwIBAgIJALOZgIbQVs/6MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYD
3 | VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g
4 | VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE
5 | AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
6 | Fw0wODA0MTUyMjQwNTBaFw0zNTA5MDEyMjQwNTBaMIGUMQswCQYDVQQGEwJVUzET
7 | MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G
8 | A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p
9 | ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI
10 | hvcNAQEBBQADggENADCCAQgCggEBAJx4BZKsDV04HN6qZezIpgBuNkgMbXIHsSAR
11 | vlCGOqvitV0Amt9xRtbyICKAx81Ne9smJDuKgGwms0sTdSOkkmgiSQTcAUk+fArP
12 | GgXIdPabA3tgMJ2QdNJCgOFrrSqHNDYZUer3KkgtCbIEsYdeEqyYwap3PWgAuer9
13 | 5W1Yvtjo2hb5o2AJnDeoNKbf7be2tEoEngeiafzPLFSW8s821k35CjuNjzSjuqtM
14 | 9TNxqydxmzulh1StDFP8FOHbRdUeI0+76TybpO35zlQmE1DsU1YHv2mi/0qgfbX3
15 | 6iANCabBtJ4hQC+J7RGQiTqrWpGA8VLoL4WkV1PPX8GQccXuyCcCAQOjgfwwgfkw
16 | HQYDVR0OBBYEFE/koLPdnLop9x1yh8Tnw48ghsKZMIHJBgNVHSMEgcEwgb6AFE/k
17 | oLPdnLop9x1yh8Tnw48ghsKZoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE
18 | CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH
19 | QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG
20 | CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJALOZgIbQVs/6MAwGA1Ud
21 | EwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBAFclUbjZOh9z3g9tRp+G2tZwFAAp
22 | PIigzXzXeLc9r8wZf6t25iEuVsHHYc/EL9cz3lLFCuCIFM78CjtaGkNGBU2Cnx2C
23 | tCsgSL+ItdFJKe+F9g7dEtctVWV+IuPoXQTIMdYT0Zk4u4mCJH+jISVroS0dao+S
24 | 6h2xw3Mxe6DAN/DRr/ZFrvIkl5+6bnoUvAJccbmBOM7z3fwFlhfPJIRc97QNY4L3
25 | J17XOElatuWTG5QhdlxJG3L7aOCA29tYwgKdNHyLMozkPvaosVUz7fvpib1qSN1L
26 | IC7alMarjdW4OZID2q4u1EYjLk/pvZYTlMYwDlE448/Shebk5INTjLixs1c=
27 | -----END CERTIFICATE-----
28 |
--------------------------------------------------------------------------------