Files
app_Settings/src/com/android/settings/applications/AppStateUsageBridge.java
Billy Lau fee785645b Bug: 22718745 Intents to 'draw over other apps' should go direct to the package's
page instead of the top level one

Settings:
Added two activities to handle app-specific Intent when app invoke permission
management UI.

SettingsActivity:
Added two fragment classes to handle app-specific Intent when app invoke permission
management UI.

AndroidManifest.xml:
We handle both Intent to top level settings and app-specific management UI for
app ops protected permissions.

AppStateAppOpsBridge:
Added a new field to PermissionState to keep track of permission declared vs one
that is actually granted during install time.

AppState{Overlay/Usage/WriteSettings}Bridge:
Updated the fields affected by changes in PermissionState.

{DrawOverlay/UsageAccess/WriteSettings}Details:
Disabled the toggling of permission if the app did not declare for the asked
permission.

Change-Id: Ibf63e4d9a4fbf7899a93d2176abb1204c4f75557
2015-07-29 23:04:57 +01:00

75 lines
2.7 KiB
Java

/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.applications;
import android.Manifest;
import android.app.AppOpsManager;
import android.content.Context;
import android.util.Log;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.AppFilter;
/*
* Connects app usage info to the ApplicationsState. Wraps around the generic AppStateAppOpsBridge
* class to tailor to the semantics of PACKAGE_USAGE_STATS. Also provides app filters that can use
* the info.
*/
public class AppStateUsageBridge extends AppStateAppOpsBridge {
private static final String TAG = "AppStateUsageBridge";
private static final String PM_USAGE_STATS = Manifest.permission.PACKAGE_USAGE_STATS;
private static final int APP_OPS_OP_CODE = AppOpsManager.OP_GET_USAGE_STATS;
public AppStateUsageBridge(Context context, ApplicationsState appState, Callback callback) {
super(context, appState, callback, APP_OPS_OP_CODE, PM_USAGE_STATS);
}
@Override
protected void updateExtraInfo(AppEntry app, String pkg, int uid) {
app.extraInfo = getUsageInfo(pkg, uid);
}
public UsageState getUsageInfo(String pkg, int uid) {
PermissionState permissionState = super.getPermissionInfo(pkg, uid);
return new UsageState(permissionState);
}
public static class UsageState extends AppStateAppOpsBridge.PermissionState {
public UsageState(PermissionState permissionState) {
super(permissionState.packageName, permissionState.userHandle);
this.packageInfo = permissionState.packageInfo;
this.appOpMode = permissionState.appOpMode;
this.permissionDeclared = permissionState.permissionDeclared;
this.staticPermissionGranted = permissionState.staticPermissionGranted;
}
}
public static final AppFilter FILTER_APP_USAGE = new AppFilter() {
@Override
public void init() {
}
@Override
public boolean filterApp(AppEntry info) {
return info.extraInfo != null;
}
};
}