App ops: new labels, fix crash, fix updating list.
- Add new labels for media ops.
- Fix crash due to missing boolean entry for access notifications op.
- Fix updating op category lists to remain stable (not jump
back to the top).
Change-Id: I505cfd91b1ff92587a627d33f3ac7a21145a9bbd
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index ccd803d..42154f4 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -589,6 +589,9 @@
<item>modify settings</item>
<item>draw on top</item>
<item>access notifications</item>
+ <item>camera</item>
+ <item>record audio</item>
+ <item>play audio</item>
</string-array>
<!-- User display names for app ops codes -->
@@ -619,6 +622,9 @@
<item>Modify settings</item>
<item>Draw on top</item>
<item>Access notifications</item>
+ <item>Camera</item>
+ <item>Record audio</item>
+ <item>Play audio</item>
</string-array>
<!-- Titles for the list of long press timeout options. -->
diff --git a/src/com/android/settings/applications/AppOpsCategory.java b/src/com/android/settings/applications/AppOpsCategory.java
index 4e426d3..125a43b 100644
--- a/src/com/android/settings/applications/AppOpsCategory.java
+++ b/src/com/android/settings/applications/AppOpsCategory.java
@@ -32,7 +32,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
+import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@@ -165,6 +165,10 @@
* Handles a request to start the Loader.
*/
@Override protected void onStartLoading() {
+ // We don't monitor changed when loading is stopped, so need
+ // to always reload at this point.
+ onContentChanged();
+
if (mApps != null) {
// If we currently have a result available, deliver it
// immediately.
@@ -239,33 +243,36 @@
}
}
- public static class AppListAdapter extends ArrayAdapter<AppOpEntry> {
+ public static class AppListAdapter extends BaseAdapter {
private final Resources mResources;
private final LayoutInflater mInflater;
private final AppOpsState mState;
+ List<AppOpEntry> mList;
+
public AppListAdapter(Context context, AppOpsState state) {
- super(context, android.R.layout.simple_list_item_2);
mResources = context.getResources();
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mState = state;
}
public void setData(List<AppOpEntry> data) {
- clear();
- if (data != null) {
- addAll(data);
- }
+ mList = data;
+ notifyDataSetChanged();
}
@Override
- public boolean hasStableIds() {
- return true;
+ public int getCount() {
+ return mList != null ? mList.size() : 0;
+ }
+
+ @Override
+ public AppOpEntry getItem(int position) {
+ return mList.get(position);
}
@Override
public long getItemId(int position) {
- // XXX need to generate real id.
return position;
}
@@ -315,16 +322,9 @@
// Start out with a progress indicator.
setListShown(false);
- }
- @Override
- public void onStart() {
- super.onStart();
-
- // Prepare the loader. We don't monitor for changes while stopped,
- // so want to re-start the loader (retrieving a new data set) each
- // time we start.
- getLoaderManager().restartLoader(0, null, this);
+ // Prepare the loader.
+ getLoaderManager().initLoader(0, null, this);
}
// utility method used to start sub activity
diff --git a/src/com/android/settings/applications/AppOpsState.java b/src/com/android/settings/applications/AppOpsState.java
index 47c4fdf..39ce0b9 100644
--- a/src/com/android/settings/applications/AppOpsState.java
+++ b/src/com/android/settings/applications/AppOpsState.java
@@ -151,11 +151,18 @@
AppOpsManager.OP_ACCESS_NOTIFICATIONS,
AppOpsManager.OP_CALL_PHONE,
AppOpsManager.OP_WRITE_SETTINGS,
- AppOpsManager.OP_SYSTEM_ALERT_WINDOW },
+ AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
+ AppOpsManager.OP_CAMERA,
+ AppOpsManager.OP_RECORD_AUDIO,
+ AppOpsManager.OP_PLAY_AUDIO },
new boolean[] { false,
false,
true,
true,
+ true,
+ true,
+ true,
+ true,
true }
);