Skip to content

Commit b137c80

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "More adjustments to permissions." into jb-mr1-dev
2 parents a40b2b3 + 2ca2c87 commit b137c80

File tree

12 files changed

+171
-66
lines changed

12 files changed

+171
-66
lines changed

api/current.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ package android {
164164
field public static final java.lang.String PERSONAL_INFO = "android.permission-group.PERSONAL_INFO";
165165
field public static final java.lang.String PHONE_CALLS = "android.permission-group.PHONE_CALLS";
166166
field public static final java.lang.String SCREENLOCK = "android.permission-group.SCREENLOCK";
167-
field public static final java.lang.String SHORTRANGE_NETWORK = "android.permission-group.SHORTRANGE_NETWORK";
168167
field public static final java.lang.String SOCIAL_INFO = "android.permission-group.SOCIAL_INFO";
169168
field public static final java.lang.String STATUS_BAR = "android.permission-group.STATUS_BAR";
170169
field public static final java.lang.String STORAGE = "android.permission-group.STORAGE";
@@ -775,6 +774,7 @@ package android {
775774
field public static final int pathPattern = 16842796; // 0x101002c
776775
field public static final int pathPrefix = 16842795; // 0x101002b
777776
field public static final int permission = 16842758; // 0x1010006
777+
field public static final int permissionFlags = 16843719; // 0x10103c7
778778
field public static final int permissionGroup = 16842762; // 0x101000a
779779
field public static final int permissionGroupFlags = 16843717; // 0x10103c5
780780
field public static final int persistent = 16842765; // 0x101000d
@@ -6743,6 +6743,7 @@ package android.content.pm {
67436743
method public int describeContents();
67446744
method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager);
67456745
field public static final android.os.Parcelable.Creator CREATOR;
6746+
field public static final int FLAG_COSTS_MONEY = 1; // 0x1
67466747
field public static final int PROTECTION_DANGEROUS = 1; // 0x1
67476748
field public static final int PROTECTION_FLAG_DEVELOPMENT = 32; // 0x20
67486749
field public static final int PROTECTION_FLAG_SYSTEM = 16; // 0x10
@@ -6752,6 +6753,7 @@ package android.content.pm {
67526753
field public static final int PROTECTION_SIGNATURE = 2; // 0x2
67536754
field public static final int PROTECTION_SIGNATURE_OR_SYSTEM = 3; // 0x3
67546755
field public int descriptionRes;
6756+
field public int flags;
67556757
field public java.lang.String group;
67566758
field public java.lang.CharSequence nonLocalizedDescription;
67576759
field public int protectionLevel;

core/java/android/content/pm/PackageParser.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,9 @@ private Permission parsePermission(Package owner, Resources res,
15431543
com.android.internal.R.styleable.AndroidManifestPermission_protectionLevel,
15441544
PermissionInfo.PROTECTION_NORMAL);
15451545

1546+
perm.info.flags = sa.getInt(
1547+
com.android.internal.R.styleable.AndroidManifestPermission_permissionFlags, 0);
1548+
15461549
sa.recycle();
15471550

15481551
if (perm.info.protectionLevel == -1) {

core/java/android/content/pm/PermissionInfo.java

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,35 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
7878
*/
7979
public static final int PROTECTION_MASK_FLAGS = 0xf0;
8080

81+
/**
82+
* The level of access this permission is protecting, as per
83+
* {@link android.R.attr#protectionLevel}. Values may be
84+
* {@link #PROTECTION_NORMAL}, {@link #PROTECTION_DANGEROUS}, or
85+
* {@link #PROTECTION_SIGNATURE}. May also include the additional
86+
* flags {@link #PROTECTION_FLAG_SYSTEM} or {@link #PROTECTION_FLAG_DEVELOPMENT}
87+
* (which only make sense in combination with the base
88+
* {@link #PROTECTION_SIGNATURE}.
89+
*/
90+
public int protectionLevel;
91+
8192
/**
8293
* The group this permission is a part of, as per
8394
* {@link android.R.attr#permissionGroup}.
8495
*/
8596
public String group;
86-
97+
98+
/**
99+
* Flag for {@link #flags}, corresponding to <code>costsMoney</code>
100+
* value of {@link android.R.attr#permissionFlags}.
101+
*/
102+
public static final int FLAG_COSTS_MONEY = 1<<0;
103+
104+
/**
105+
* Additional flags about this permission as given by
106+
* {@link android.R.attr#permissionFlags}.
107+
*/
108+
public int flags;
109+
87110
/**
88111
* A string resource identifier (in the package's resources) of this
89112
* permission's description. From the "description" attribute or,
@@ -99,17 +122,6 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
99122
*/
100123
public CharSequence nonLocalizedDescription;
101124

102-
/**
103-
* The level of access this permission is protecting, as per
104-
* {@link android.R.attr#protectionLevel}. Values may be
105-
* {@link #PROTECTION_NORMAL}, {@link #PROTECTION_DANGEROUS}, or
106-
* {@link #PROTECTION_SIGNATURE}. May also include the additional
107-
* flags {@link #PROTECTION_FLAG_SYSTEM} or {@link #PROTECTION_FLAG_DEVELOPMENT}
108-
* (which only make sense in combination with the base
109-
* {@link #PROTECTION_SIGNATURE}.
110-
*/
111-
public int protectionLevel;
112-
113125
/** @hide */
114126
public static int fixProtectionLevel(int level) {
115127
if (level == PROTECTION_SIGNATURE_OR_SYSTEM) {
@@ -149,9 +161,10 @@ public PermissionInfo() {
149161

150162
public PermissionInfo(PermissionInfo orig) {
151163
super(orig);
164+
protectionLevel = orig.protectionLevel;
165+
flags = orig.flags;
152166
group = orig.group;
153167
descriptionRes = orig.descriptionRes;
154-
protectionLevel = orig.protectionLevel;
155168
nonLocalizedDescription = orig.nonLocalizedDescription;
156169
}
157170

@@ -191,9 +204,10 @@ public int describeContents() {
191204

192205
public void writeToParcel(Parcel dest, int parcelableFlags) {
193206
super.writeToParcel(dest, parcelableFlags);
207+
dest.writeInt(protectionLevel);
208+
dest.writeInt(flags);
194209
dest.writeString(group);
195210
dest.writeInt(descriptionRes);
196-
dest.writeInt(protectionLevel);
197211
TextUtils.writeToParcel(nonLocalizedDescription, dest, parcelableFlags);
198212
}
199213

@@ -209,9 +223,10 @@ public PermissionInfo[] newArray(int size) {
209223

210224
private PermissionInfo(Parcel source) {
211225
super(source);
226+
protectionLevel = source.readInt();
227+
flags = source.readInt();
212228
group = source.readString();
213229
descriptionRes = source.readInt();
214-
protectionLevel = source.readInt();
215230
nonLocalizedDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
216231
}
217232
}

core/java/android/widget/AppSecurityPermissions.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class AppSecurityPermissions {
6767
public static final int WHICH_ALL = 0xffff;
6868

6969
private final static String TAG = "AppSecurityPermissions";
70-
private boolean localLOGV = false;
70+
private final static boolean localLOGV = false;
7171
private Context mContext;
7272
private LayoutInflater mInflater;
7373
private PackageManager mPm;
@@ -189,6 +189,8 @@ public void setPermission(MyPermissionGroupInfo grp, MyPermissionInfo perm,
189189
permGrpIcon.setImageDrawable(icon);
190190
permNameView.setText(label);
191191
setOnClickListener(this);
192+
if (localLOGV) Log.i(TAG, "Made perm item " + perm.name
193+
+ ": " + label + " in group " + grp.name);
192194
}
193195

194196
@Override
@@ -531,7 +533,9 @@ private static PermissionItemView getPermissionItemView(Context context, LayoutI
531533
MyPermissionGroupInfo grp, MyPermissionInfo perm, boolean first,
532534
CharSequence newPermPrefix) {
533535
PermissionItemView permView = (PermissionItemView)inflater.inflate(
534-
R.layout.app_permission_item, null);
536+
(perm.flags & PermissionInfo.FLAG_COSTS_MONEY) != 0
537+
? R.layout.app_permission_item_money : R.layout.app_permission_item,
538+
null);
535539
permView.setPermission(grp, perm, first, newPermPrefix);
536540
return permView;
537541
}
@@ -568,6 +572,8 @@ private boolean isDisplayablePermission(PermissionInfo pInfo, int newReqFlags,
568572
// already granted, they will not be granted as part of the install.
569573
if ((existingReqFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0
570574
&& (pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
575+
if (localLOGV) Log.i(TAG, "Special perm " + pInfo.name
576+
+ ": protlevel=0x" + Integer.toHexString(pInfo.protectionLevel));
571577
return true;
572578
}
573579
return false;
@@ -650,9 +656,9 @@ private void setPermissions(List<MyPermissionInfo> permList) {
650656
mPermGroupsList.add(pgrp);
651657
}
652658
Collections.sort(mPermGroupsList, mPermGroupComparator);
653-
if (false) {
659+
if (localLOGV) {
654660
for (MyPermissionGroupInfo grp : mPermGroupsList) {
655-
Log.i("foo", "Group " + grp.name + " personal="
661+
Log.i(TAG, "Group " + grp.name + " personal="
656662
+ ((grp.flags&PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0)
657663
+ " priority=" + grp.priority);
658664
}

core/res/AndroidManifest.xml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
<permission android:name="android.permission.SEND_SMS"
172172
android:permissionGroup="android.permission-group.MESSAGES"
173173
android:protectionLevel="dangerous"
174+
android:permissionFlags="costsMoney"
174175
android:label="@string/permlab_sendSms"
175176
android:description="@string/permdesc_sendSms" />
176177

@@ -404,7 +405,6 @@
404405
android:label="@string/permgrouplab_writeDictionary"
405406
android:icon="@drawable/perm_group_user_dictionary_write"
406407
android:description="@string/permgroupdesc_writeDictionary"
407-
android:permissionGroupFlags="personalInfo"
408408
android:priority="160" />
409409

410410
<!-- Allows an application to write to the user dictionary. -->
@@ -515,14 +515,14 @@
515515

516516
<!-- Allows an application to create mock location providers for testing -->
517517
<permission android:name="android.permission.ACCESS_MOCK_LOCATION"
518-
android:permissionGroup="android.permission-group.LOCATION"
518+
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
519519
android:protectionLevel="dangerous"
520520
android:label="@string/permlab_accessMockLocation"
521521
android:description="@string/permdesc_accessMockLocation" />
522522

523523
<!-- Allows an application to access extra location provider commands -->
524524
<permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"
525-
android:permissionGroup="android.permission-group.LOCATION"
525+
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
526526
android:protectionLevel="normal"
527527
android:label="@string/permlab_accessLocationExtraCommands"
528528
android:description="@string/permdesc_accessLocationExtraCommands" />
@@ -616,24 +616,14 @@
616616
android:description="@string/permdesc_bluetoothAdmin"
617617
android:label="@string/permlab_bluetoothAdmin" />
618618

619-
<!-- Used for permissions that provide access to network services that
620-
are for peripherals and other nearby devices. These networks
621-
generally do not provide IP based networking or internet access.-->
622-
<permission-group android:name="android.permission-group.SHORTRANGE_NETWORK"
623-
android:label="@string/permgrouplab_shortrangeNetwork"
624-
android:icon="@drawable/perm_group_shortrange_network"
625-
android:description="@string/permgroupdesc_shortrangeNetwork"
626-
android:priority="250" />
627-
628619
<!-- Allows applications to perform I/O operations over NFC -->
629620
<permission android:name="android.permission.NFC"
630-
android:permissionGroup="android.permission-group.SHORTRANGE_NETWORK"
621+
android:permissionGroup="android.permission-group.NETWORK"
631622
android:protectionLevel="dangerous"
632623
android:description="@string/permdesc_nfc"
633624
android:label="@string/permlab_nfc" />
634625

635-
<!-- Allows an internal user to use privileged ConnectivityManager
636-
APIs.
626+
<!-- Allows an internal user to use privileged ConnectivityManager APIs.
637627
@hide -->
638628
<permission android:name="android.permission.CONNECTIVITY_INTERNAL"
639629
android:permissionGroup="android.permission-group.NETWORK"
@@ -904,6 +894,7 @@
904894
<permission android:name="android.permission.CALL_PHONE"
905895
android:permissionGroup="android.permission-group.PHONE_CALLS"
906896
android:protectionLevel="dangerous"
897+
android:permissionFlags="costsMoney"
907898
android:label="@string/permlab_callPhone"
908899
android:description="@string/permdesc_callPhone" />
909900

@@ -929,7 +920,7 @@
929920

930921
<!-- Allows an application to read from external storage -->
931922
<permission android:name="android.permission.READ_EXTERNAL_STORAGE"
932-
android:permissionGroup="android.permission-group.DEVELOPMENT_TOOLS"
923+
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
933924
android:label="@string/permlab_sdcardRead"
934925
android:description="@string/permdesc_sdcardRead"
935926
android:protectionLevel="normal" />
@@ -1227,7 +1218,7 @@
12271218
<!-- Allows an application to modify the current configuration, such
12281219
as locale. -->
12291220
<permission android:name="android.permission.CHANGE_CONFIGURATION"
1230-
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
1221+
android:permissionGroup="android.permission-group.DEVELOPMENT_TOOLS"
12311222
android:protectionLevel="signature|system|development"
12321223
android:label="@string/permlab_changeConfiguration"
12331224
android:description="@string/permdesc_changeConfiguration" />
@@ -1287,7 +1278,7 @@
12871278
<!-- @deprecated This functionality will be removed in the future; please do
12881279
not use. Allow an application to make its activities persistent. -->
12891280
<permission android:name="android.permission.PERSISTENT_ACTIVITY"
1290-
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
1281+
android:permissionGroup="android.permission-group.APP_INFO"
12911282
android:protectionLevel="normal"
12921283
android:label="@string/permlab_persistentActivity"
12931284
android:description="@string/permdesc_persistentActivity" />
@@ -1320,7 +1311,7 @@
13201311
explicitly declare your use of this facility to make that visible
13211312
to the user. -->
13221313
<permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"
1323-
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
1314+
android:permissionGroup="android.permission-group.APP_INFO"
13241315
android:protectionLevel="normal"
13251316
android:label="@string/permlab_receiveBootCompleted"
13261317
android:description="@string/permdesc_receiveBootCompleted" />
@@ -1411,7 +1402,7 @@
14111402

14121403
<!-- Allows applications to change network connectivity state -->
14131404
<permission android:name="android.permission.CHANGE_NETWORK_STATE"
1414-
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
1405+
android:permissionGroup="android.permission-group.NETWORK"
14151406
android:protectionLevel="normal"
14161407
android:description="@string/permdesc_changeNetworkState"
14171408
android:label="@string/permlab_changeNetworkState" />
@@ -1535,8 +1526,8 @@
15351526
<!-- Allows an application to update device statistics. Not for
15361527
use by third party apps. -->
15371528
<permission android:name="android.permission.UPDATE_DEVICE_STATS"
1538-
android:label="@string/permlab_batteryStats"
1539-
android:description="@string/permdesc_batteryStats"
1529+
android:label="@string/permlab_updateBatteryStats"
1530+
android:description="@string/permdesc_updateBatteryStats"
15401531
android:protectionLevel="signature|system" />
15411532

15421533
<!-- Allows an application to open windows that are for use by parts
@@ -1854,9 +1845,10 @@
18541845

18551846
<!-- Allows an application to collect battery statistics -->
18561847
<permission android:name="android.permission.BATTERY_STATS"
1848+
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
18571849
android:label="@string/permlab_batteryStats"
18581850
android:description="@string/permdesc_batteryStats"
1859-
android:protectionLevel="normal" />
1851+
android:protectionLevel="dangerous" />
18601852

18611853
<!-- Allows an application to control the backup and restore process
18621854
@hide pending API council -->

core/res/res/layout/app_permission_item.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
<!--
1818
Defines the layout of a single permission item.
19-
Contains the group name and a list of permission labels under the group.
2019
-->
2120

2221
<view class="android.widget.AppSecurityPermissions$PermissionItemView"
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="utf-8"?>
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+
<!--
18+
Defines the layout of a single permission item that costs money.
19+
-->
20+
21+
<view class="android.widget.AppSecurityPermissions$PermissionItemView"
22+
xmlns:android="http://schemas.android.com/apk/res/android"
23+
android:layout_width="match_parent"
24+
android:layout_height="wrap_content"
25+
android:orientation="horizontal"
26+
android:background="?android:attr/selectableItemBackground">
27+
28+
<ImageView
29+
android:id="@+id/perm_icon"
30+
android:layout_width="32dp"
31+
android:layout_height="32dp"
32+
android:layout_marginStart="16dp"
33+
android:layout_marginEnd="8dp"
34+
android:scaleType="fitCenter" />
35+
36+
<ImageView
37+
android:layout_width="wrap_content"
38+
android:layout_height="match_parent"
39+
android:background="?android:attr/dividerVertical" />
40+
41+
<RelativeLayout
42+
android:layout_width="match_parent"
43+
android:layout_height="wrap_content"
44+
android:layout_marginStart="8dp">
45+
<TextView
46+
android:id="@+id/perm_name"
47+
android:textAppearance="?android:attr/textAppearanceSmall"
48+
android:textSize="16sp"
49+
android:layout_width="wrap_content"
50+
android:layout_height="wrap_content"
51+
android:layout_alignParentStart="true"
52+
android:layout_alignParentTop="true" />
53+
<ImageView
54+
android:id="@+id/perm_money_icon"
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content"
57+
android:layout_alignParentStart="true"
58+
android:layout_below="@id/perm_name"
59+
android:scaleType="fitCenter" />
60+
<TextView
61+
android:textAppearance="?android:attr/textAppearanceSmall"
62+
android:textSize="16sp"
63+
android:textColor="@color/perms_costs_money"
64+
android:layout_width="wrap_content"
65+
android:layout_height="wrap_content"
66+
android:layout_toEndOf="@id/perm_money_icon"
67+
android:layout_below="@id/perm_name"
68+
android:text="@string/perm_costs_money" />
69+
</RelativeLayout>
70+
71+
</view>

0 commit comments

Comments
 (0)