am bc3695c2
: am e267fb31
: am d06ba151
: Merge "Bug 21589105 Rescope WRITE_SETTINGS (UX and Settings app change)..." into mnc-dev
* commit 'bc3695c231a5a16f45059e0e561a35d49353afc5': Bug 21589105 Rescope WRITE_SETTINGS (UX and Settings app change)...
This commit is contained in:
@@ -2548,6 +2548,8 @@
|
||||
<action android:name="android.settings.action.MANAGE_WRITE_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.applications.ManageApplications" />
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
@@ -6868,7 +6868,7 @@
|
||||
<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=45] -->
|
||||
<!-- Title of Draw Overlay preference item [CHAR LIMIT=55] -->
|
||||
<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>
|
||||
|
@@ -60,15 +60,12 @@ public class AppStateWriteSettingsBridge extends AppStateAppOpsBridge {
|
||||
return super.getNumPackagesAllowedByAppOps();
|
||||
}
|
||||
|
||||
public static class WriteSettingsState {
|
||||
PermissionState mPermissionState;
|
||||
|
||||
public static class WriteSettingsState extends AppStateAppOpsBridge.PermissionState {
|
||||
public WriteSettingsState(PermissionState permissionState) {
|
||||
mPermissionState = permissionState;
|
||||
}
|
||||
|
||||
public boolean canWrite() {
|
||||
return mPermissionState.isPermissible();
|
||||
super(permissionState.packageName, permissionState.userHandle);
|
||||
this.packageInfo = permissionState.packageInfo;
|
||||
this.appOpMode = permissionState.appOpMode;
|
||||
this.permissionDeclared = permissionState.permissionDeclared;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.preference.Preference;
|
||||
@@ -36,6 +35,7 @@ import android.util.Log;
|
||||
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.AppStateWriteSettingsBridge.WriteSettingsState;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
@@ -98,7 +98,7 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
||||
try {
|
||||
getActivity().startActivityAsUser(mSettingsIntent, new UserHandle(mUserId));
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.w(TAG, "Unable to launch write system settings " + mSettingsIntent, e);
|
||||
Log.w(LOG_TAG, "Unable to launch write system settings " + mSettingsIntent, e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -109,8 +109,9 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mSwitchPref) {
|
||||
if (mWriteSettingsState != null && (Boolean) newValue != mWriteSettingsState.canWrite()) {
|
||||
setCanWriteSettings(!mWriteSettingsState.canWrite());
|
||||
if (mWriteSettingsState != null && (Boolean) newValue != mWriteSettingsState
|
||||
.isPermissible()) {
|
||||
setCanWriteSettings(!mWriteSettingsState.isPermissible());
|
||||
refreshUi();
|
||||
}
|
||||
return true;
|
||||
@@ -122,7 +123,6 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
||||
mAppOpsManager.setMode(AppOpsManager.OP_WRITE_SETTINGS,
|
||||
mPackageInfo.applicationInfo.uid, mPackageName, newState
|
||||
? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_ERRORED);
|
||||
canWriteSettings(mPackageName);
|
||||
}
|
||||
|
||||
private boolean canWriteSettings(String pkgName) {
|
||||
@@ -140,17 +140,10 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
||||
mWriteSettingsState = mAppBridge.getWriteSettingsInfo(mPackageName,
|
||||
mPackageInfo.applicationInfo.uid);
|
||||
|
||||
boolean canWrite = mWriteSettingsState.canWrite();
|
||||
boolean canWrite = mWriteSettingsState.isPermissible();
|
||||
mSwitchPref.setChecked(canWrite);
|
||||
mWriteSettingsPrefs.setEnabled(canWrite);
|
||||
|
||||
ResolveInfo resolveInfo = mPm.resolveActivityAsUser(mSettingsIntent,
|
||||
PackageManager.GET_META_DATA, mUserId);
|
||||
if (resolveInfo == null) {
|
||||
if (findPreference(KEY_APP_OPS_SETTINGS_PREFS) != null) {
|
||||
getPreferenceScreen().removePreference(mWriteSettingsPrefs);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -166,9 +159,20 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
||||
}
|
||||
|
||||
public static CharSequence getSummary(Context context, AppEntry entry) {
|
||||
if (entry.extraInfo != null) {
|
||||
return getSummary(context, new WriteSettingsState((PermissionState)entry
|
||||
.extraInfo));
|
||||
}
|
||||
|
||||
// fallback if entry.extrainfo is null - although this should not happen
|
||||
return getSummary(context, entry.info.packageName);
|
||||
}
|
||||
|
||||
public static CharSequence getSummary(Context context, WriteSettingsState writeSettingsState) {
|
||||
return context.getString(writeSettingsState.isPermissible() ? R.string.write_settings_on :
|
||||
R.string.write_settings_off);
|
||||
}
|
||||
|
||||
public static CharSequence getSummary(Context context, String pkg) {
|
||||
// first check if pkg is a system pkg
|
||||
boolean isSystem = false;
|
||||
@@ -180,8 +184,8 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// pkg doesn't even exist?
|
||||
Log.w(TAG, "Package " + pkg + " not found", e);
|
||||
return context.getString(R.string.system_alert_window_off);
|
||||
Log.w(LOG_TAG, "Package " + pkg + " not found", e);
|
||||
return context.getString(R.string.write_settings_off);
|
||||
}
|
||||
|
||||
AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context
|
||||
@@ -189,7 +193,7 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
||||
List<AppOpsManager.PackageOps> packageOps = appOpsManager.getPackagesForOps(
|
||||
APP_OPS_OP_CODE);
|
||||
if (packageOps == null) {
|
||||
return context.getString(R.string.system_alert_window_off);
|
||||
return context.getString(R.string.write_settings_off);
|
||||
}
|
||||
|
||||
int uid = isSystem ? 0 : -1;
|
||||
@@ -201,7 +205,7 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
||||
}
|
||||
|
||||
if (uid == -1) {
|
||||
return context.getString(R.string.system_alert_window_off);
|
||||
return context.getString(R.string.write_settings_off);
|
||||
}
|
||||
|
||||
int mode = appOpsManager.noteOpNoThrow(AppOpsManager.OP_WRITE_SETTINGS, uid, pkg);
|
||||
|
Reference in New Issue
Block a user