<string name="accessibility_lock_screen_progress"><xliff:g id="count" example="1">%1$d</xliff:g> of <xliff:g id="count" example="1">%2$d</xliff:g> characters used</string>
<!-- System Alert Window settings -->
- <!-- Title of Draw Overlay preference item [CHAR LIMIT=30] -->
- <string name="draw_overlay_title">Apps that can draw overlay</string>
+ <!-- Title of Draw Overlay preference item [CHAR LIMIT=45] -->
+ <string name="draw_overlay_title">Apps that can draw over other apps</string>
<!-- Title of draw overlay screen [CHAR LIMIT=30] -->
<string name="draw_overlay">Draw over other apps</string>
<!-- Settings title in main settings screen for SYSTEM_ALERT_WINDOW [CHAR LIMIT=45] -->
<!-- Title for the apps with SYSTEM_ALERT_WINDOW permission/privilege [CHAR LIMIT=20] -->
<string name="system_alert_window_apps_title">Apps</string>
<!-- Title for the apps that are allowed to draw on top of other apps [CHAR LIMIT=60] -->
- <string name="system_alert_window_access_title">Can draw overlays</string>
+ <string name="system_alert_window_access_title">Draw over other apps</string>
<!-- Label for setting which controls whether app can draw overlays [CHAR LIMIT=45] -->
- <string name="permit_draw_overlay">Permit drawing overlays</string>
+ <string name="permit_draw_overlay">Permit drawing over other apps</string>
<!-- Link to the apps page for SYSTEM_ALERT_WINDOW settings [CHAR LIMIT=45] -->
<string name="app_overlay_permission_preference">App draw on top permission</string>
<!-- Description of allowing overlay setting [CHAR LIMIT=NONE] -->
<!-- Keyword for SYSTEM_ALERT_WINDOW -->
<string name="keywords_system_alert_window">system alert window dialog draw on top other apps</string>
- <!-- Main settings screen item's title to go into the overlay settings screen [CHAR LIMIT=25] -->
- <string name="overlay_settings">Overlay settings</string>
+ <!-- Main settings screen item's title to go into the overlay settings screen [CHAR LIMIT=30] -->
+ <string name="overlay_settings">Draw over other apps</string>
<!-- Summary of number of apps currently can draw overlays [CHAR LIMIT=60] -->
<string name="system_alert_window_summary"><xliff:g id="count" example="10">%d</xliff:g> of <xliff:g id="count" example="10">%d</xliff:g> apps allowed to draw on top of other apps</string>
<string name="filter_write_settings_apps">Can write system settings</string>
<!-- Title for the apps that are allowed to write system settings [CHAR LIMIT=60] -->
<string name="write_settings_title">Can write system settings</string>
- <!-- Main settings screen item's title to go into the write system settings screen [CHAR LIMIT=25] -->
+ <!-- Main settings screen item's title to go into the write system settings screen [CHAR LIMIT=30] -->
<string name="write_system_settings">Write system settings</string>
- <!-- Link to the apps page for WRITE_SETTINGS settings [CHAR LIMIT=45] -->
+ <!-- Link to the apps page for WRITE_SETTINGS settings [CHAR LIMIT=52] -->
<string name="write_settings_preference">App write system settings permission</string>
<!-- Label for setting which controls whether app can write system settings [CHAR LIMIT=45] -->
<string name="permit_write_settings">Allow write system settings</string>
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.UserHandle;
import android.preference.Preference;
import com.android.internal.logging.MetricsLogger;
import com.android.settings.InstrumentedFragment;
import com.android.settings.R;
+import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
import com.android.settings.applications.AppStateOverlayBridge.OverlayState;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
try {
getActivity().startActivityAsUser(mSettingsIntent, new UserHandle(mUserId));
} catch (ActivityNotFoundException e) {
- Log.w(TAG, "Unable to launch app draw overlay settings " + mSettingsIntent, e);
+ Log.w(LOG_TAG, "Unable to launch app draw overlay settings " + mSettingsIntent, e);
}
}
return true;
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == mSwitchPref) {
- if (mOverlayState != null && (Boolean) newValue != mOverlayState.isAllowed()) {
- setCanDrawOverlay(!mOverlayState.isAllowed());
+ if (mOverlayState != null && (Boolean) newValue != mOverlayState.isPermissible()) {
+ setCanDrawOverlay(!mOverlayState.isPermissible());
refreshUi();
}
return true;
mAppOpsManager.setMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
mPackageInfo.applicationInfo.uid, mPackageName, newState
? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_ERRORED);
- canDrawOverlay(mPackageName);
}
private boolean canDrawOverlay(String pkgName) {
mOverlayState = mOverlayBridge.getOverlayInfo(mPackageName,
mPackageInfo.applicationInfo.uid);
- boolean isAllowed = mOverlayState.isAllowed();
+ boolean isAllowed = mOverlayState.isPermissible();
mSwitchPref.setChecked(isAllowed);
mOverlayPrefs.setEnabled(isAllowed);
-
- ResolveInfo resolveInfo = mPm.resolveActivityAsUser(mSettingsIntent,
- PackageManager.GET_META_DATA, mUserId);
- if (resolveInfo == null) {
- if (findPreference(KEY_APP_OPS_SETTINGS_PREFS) != null) {
- getPreferenceScreen().removePreference(mOverlayPrefs);
- }
- }
+ getPreferenceScreen().removePreference(mOverlayPrefs);
return true;
}
}
public static CharSequence getSummary(Context context, AppEntry entry) {
+ if (entry.extraInfo != null) {
+ return getSummary(context, new OverlayState((PermissionState)entry.extraInfo));
+ }
+
+ // fallback if for whatever reason entry.extrainfo is null - the result
+ // may be less accurate
return getSummary(context, entry.info.packageName);
}
+ public static CharSequence getSummary(Context context, OverlayState overlayState) {
+ return context.getString(overlayState.isPermissible() ?
+ R.string.system_alert_window_on : R.string.system_alert_window_off);
+ }
+
public static CharSequence getSummary(Context context, String pkg) {
// first check if pkg is a system pkg
- boolean isSystem = false;
PackageManager packageManager = context.getPackageManager();
+ int uid = -1;
try {
ApplicationInfo appInfo = packageManager.getApplicationInfo(pkg, 0);
+ uid = appInfo.uid;
if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
- isSystem = true;
+ return context.getString(R.string.system_alert_window_on);
}
} catch (PackageManager.NameNotFoundException e) {
// pkg doesn't even exist?
- Log.w(TAG, "Package " + pkg + " not found", e);
+ Log.w(LOG_TAG, "Package " + pkg + " not found", e);
return context.getString(R.string.system_alert_window_off);
}
AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context
.APP_OPS_SERVICE);
- List<AppOpsManager.PackageOps> packageOps = appOpsManager.getPackagesForOps(
- APP_OPS_OP_CODE);
- if (packageOps == null) {
- return context.getString(R.string.system_alert_window_off);
- }
-
- int uid = isSystem ? 0 : -1;
- for (AppOpsManager.PackageOps packageOp : packageOps) {
- if (pkg.equals(packageOp.getPackageName())) {
- uid = packageOp.getUid();
- break;
- }
- }
-
if (uid == -1) {
return context.getString(R.string.system_alert_window_off);
}