packages/apps/Settings
Revision | ec84d44abfcf0048c1593654999a19593e100458 (tree) |
---|---|
Zeit | 2019-05-20 18:35:01 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Merge tag 'android-8.1.0_r64' into oreo-x86
Android 8.1.0 Release 64 (OPM8.190505.001)
@@ -16,6 +16,8 @@ | ||
16 | 16 | |
17 | 17 | package com.android.settings; |
18 | 18 | |
19 | +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; | |
20 | + | |
19 | 21 | import android.content.ComponentName; |
20 | 22 | import android.content.Context; |
21 | 23 | import android.content.DialogInterface; |
@@ -30,6 +32,8 @@ import android.text.TextUtils; | ||
30 | 32 | import android.view.LayoutInflater; |
31 | 33 | import android.view.View; |
32 | 34 | import android.view.ViewGroup; |
35 | +import android.view.Window; | |
36 | +import android.view.WindowManager; | |
33 | 37 | import android.widget.BaseAdapter; |
34 | 38 | import android.widget.ImageView; |
35 | 39 | import android.widget.TextView; |
@@ -60,6 +64,22 @@ public final class SmsDefaultDialog extends AlertActivity implements | ||
60 | 64 | } |
61 | 65 | |
62 | 66 | @Override |
67 | + protected void onStart() { | |
68 | + super.onStart(); | |
69 | + getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); | |
70 | + android.util.EventLog.writeEvent(0x534e4554, "120484087", -1, ""); | |
71 | + } | |
72 | + | |
73 | + @Override | |
74 | + protected void onStop() { | |
75 | + super.onStop(); | |
76 | + final Window window = getWindow(); | |
77 | + final WindowManager.LayoutParams attrs = window.getAttributes(); | |
78 | + attrs.privateFlags &= ~PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; | |
79 | + window.setAttributes(attrs); | |
80 | + } | |
81 | + | |
82 | + @Override | |
63 | 83 | public void onClick(DialogInterface dialog, int which) { |
64 | 84 | switch (which) { |
65 | 85 | case BUTTON_POSITIVE: |
@@ -84,7 +104,7 @@ public final class SmsDefaultDialog extends AlertActivity implements | ||
84 | 104 | } |
85 | 105 | |
86 | 106 | private boolean buildDialog(String packageName) { |
87 | - TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); | |
107 | + TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); | |
88 | 108 | if (!tm.isSmsCapable()) { |
89 | 109 | // No phone, no SMS |
90 | 110 | return false; |
@@ -198,7 +218,7 @@ public final class SmsDefaultDialog extends AlertActivity implements | ||
198 | 218 | } else { |
199 | 219 | view.findViewById(R.id.default_label).setVisibility(View.GONE); |
200 | 220 | } |
201 | - ImageView imageView = (ImageView)view.findViewById(android.R.id.icon); | |
221 | + ImageView imageView = (ImageView) view.findViewById(android.R.id.icon); | |
202 | 222 | imageView.setImageDrawable(item.icon); |
203 | 223 | return view; |
204 | 224 | } |
@@ -18,6 +18,8 @@ package com.android.settings.development; | ||
18 | 18 | |
19 | 19 | import android.content.Context; |
20 | 20 | import android.content.SharedPreferences; |
21 | +import android.os.Build; | |
22 | +import android.os.UserManager; | |
21 | 23 | import android.provider.Settings; |
22 | 24 | |
23 | 25 | import com.android.settingslib.core.lifecycle.Lifecycle; |
@@ -53,6 +55,17 @@ public class DevelopmentSettingsEnabler implements LifecycleObserver, OnResume { | ||
53 | 55 | Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1); |
54 | 56 | } |
55 | 57 | |
58 | + public static boolean isDevelopmentSettingsEnabled(Context context) { | |
59 | + final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); | |
60 | + final boolean settingEnabled = Settings.Global.getInt(context.getContentResolver(), | |
61 | + Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, | |
62 | + Build.TYPE.equals("eng") ? 1 : 0) != 0; | |
63 | + final boolean hasRestriction = um.hasUserRestriction( | |
64 | + UserManager.DISALLOW_DEBUGGING_FEATURES); | |
65 | + final boolean isAdminOrDemo = um.isAdminUser() || um.isDemoUser(); | |
66 | + return isAdminOrDemo && !hasRestriction && settingEnabled; | |
67 | + } | |
68 | + | |
56 | 69 | private void updateEnabledState() { |
57 | 70 | mLastEnabledState = Settings.Global.getInt(mContext.getContentResolver(), |
58 | 71 | Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; |
@@ -16,20 +16,29 @@ | ||
16 | 16 | |
17 | 17 | package com.android.settings.qstile; |
18 | 18 | |
19 | +import android.content.ComponentName; | |
20 | +import android.content.Context; | |
21 | +import android.content.pm.PackageManager; | |
19 | 22 | import android.os.RemoteException; |
23 | +import android.os.ServiceManager; | |
20 | 24 | import android.os.SystemProperties; |
21 | 25 | import android.provider.Settings; |
22 | 26 | import android.service.quicksettings.Tile; |
23 | 27 | import android.service.quicksettings.TileService; |
28 | +import android.util.EventLog; | |
29 | +import android.util.Log; | |
24 | 30 | import android.view.IWindowManager; |
25 | 31 | import android.view.ThreadedRenderer; |
26 | 32 | import android.view.View; |
27 | 33 | import android.view.WindowManagerGlobal; |
28 | 34 | |
29 | 35 | import com.android.internal.app.LocalePicker; |
36 | +import com.android.internal.statusbar.IStatusBarService; | |
37 | +import com.android.settings.development.DevelopmentSettingsEnabler; | |
30 | 38 | import com.android.settings.development.DevelopmentSettings; |
31 | 39 | |
32 | 40 | public abstract class DevelopmentTiles extends TileService { |
41 | + private static final String TAG = "DevelopmentTiles"; | |
33 | 42 | |
34 | 43 | protected abstract boolean isEnabled(); |
35 | 44 |
@@ -42,7 +51,33 @@ public abstract class DevelopmentTiles extends TileService { | ||
42 | 51 | } |
43 | 52 | |
44 | 53 | public void refresh() { |
45 | - getQsTile().setState(isEnabled() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE); | |
54 | + final int state; | |
55 | + if (!DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this)) { | |
56 | + // Reset to disabled state if dev option is off. | |
57 | + if (isEnabled()) { | |
58 | + setIsEnabled(false); | |
59 | + new DevelopmentSettings.SystemPropPoker().execute(); | |
60 | + } | |
61 | + final ComponentName cn = new ComponentName(getPackageName(), getClass().getName()); | |
62 | + try { | |
63 | + getPackageManager().setComponentEnabledSetting( | |
64 | + cn, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, | |
65 | + PackageManager.DONT_KILL_APP); | |
66 | + final IStatusBarService statusBarService = IStatusBarService.Stub.asInterface( | |
67 | + ServiceManager.checkService(Context.STATUS_BAR_SERVICE)); | |
68 | + if (statusBarService != null) { | |
69 | + EventLog.writeEvent(0x534e4554, "117770924"); // SaftyNet | |
70 | + statusBarService.remTile(cn); | |
71 | + } | |
72 | + } catch (RemoteException e) { | |
73 | + Log.e(TAG, "Failed to modify QS tile for component " + | |
74 | + cn.toString(), e); | |
75 | + } | |
76 | + state = Tile.STATE_UNAVAILABLE; | |
77 | + } else { | |
78 | + state = isEnabled() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; | |
79 | + } | |
80 | + getQsTile().setState(state); | |
46 | 81 | getQsTile().updateTile(); |
47 | 82 | } |
48 | 83 |
@@ -131,4 +166,4 @@ public abstract class DevelopmentTiles extends TileService { | ||
131 | 166 | } catch (RemoteException e) { } |
132 | 167 | } |
133 | 168 | } |
134 | -} | |
\ No newline at end of file | ||
169 | +} |