How to set default settings in android overlay (captive portal mode) - settings

I am working an aosp project. For this project, I want to set the captive portal check off by default in the aosp build. I figured and tested that I can set the setting via:
settings put global captive_portal_detection_enabled 0
see also https://www.kuketz-blog.de/android-captive-portal-check-aenderung/
So usually I will set this by using the overlay mechanism for the resources in the device, for example in overlay/frameworks/base/core/packages/settingsprovider/res/value:
<resources>
<!-- disable lockscreen by default to avoid showing of user switcher -->
<bool name="def_lockscreen_disabled">true</bool>
</resources>
I figured, that the default value for the captive portal is in the aosp ConnectivityService defined like
private int getCaptivePortalMode() {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.CAPTIVE_PORTAL_MODE,
Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT);
}
I tried several ways to override it but prepending config_ or _def does not work, adding the entry by
<resources>
<!-- disable captive portal checking -->
<add-resource type="integer" name="config_captive_portal_mode"/>
<integer name="config_captive_portal_mode">0</integer>
</resources>
now I only have 2 options left, but I do not like any of them:
a) patch aosp -> have troubles with updates
b) run a script on the first startup -> ugly
Did I miss something?

Alains answer is what I was looking for.
You'd need to add some logic to check whether the device is booting
for the first time or not, through a file in userdata for example.

To add a default value for CAPTIVE_PORTAL_MODE make the below changes in
DatabaseHelper under framework/base/packages/SettingsProvider/src
loadIntegerSetting(stmt, Settings.Global.CAPTIVE_PORTAL_MODE,
R.integer.def_captive_portal_detection_enabled);
Default.xml under framework/base/packages/SettingsProvider/res
<integer name="def_captive_portal_detection_enabled" translatable="false">0</integer>

Related

No active configuration. Make sure GIDClientID is set in Info.plist

I am very new to app development. I was trying to configure my GoogleSignInButton Callback function.
I get the error:
No active configuration. Make sure GIDClientID is set in Info.plist.
However, my Info.plist defines GIDClientID along with the value generated as advised here
OS: Version 13.0 Beta
Xcode: Version 14.1 beta 3
In order to resolve this issues, you don't need to add anything into the info.plist. you need to setup GIDSignIn.sharedInstance.configuration = config
https://github.com/WesCSK/SwiftUI-Firebase-Authenticate-Using-Google-Sign-In/blob/starting/README.md#updated-steps-for-v700-of-google-signin
guard let clientID = FirebaseApp.app()?.options.clientID else { return }
// Create Google Sign In configuration object.
let config = GIDConfiguration(clientID: clientID)
GIDSignIn.sharedInstance.configuration = config
....
Google documentation at Firebase Login methods is worse than....
So, if you are using 8.6.0 you can use GIDSignIn.sharedInstance.signIn(withPresenting: presentingVC), but add ClientID in Info.plist like here:
enter image description here
Regarding the main issue, from your picture I see that you put the URLSchema at GIDClientID, they are a little bit different.
Eg. GIDclientID: xxxx-xxxxxx.apps.googleusercontent.com
URLSchema: com.googleusercontent.apps.xxxx-xxxxxx.
Try like that.
I get my clientId using this line of debug in my code
guard let clientID = FirebaseApp.app()?.options.clientID
Same error. I'm newbie too, it helped for me to reinstall packages (GoogleSignIn and FirebaseAuth) with older versions (6.0.0 and 8.6.0) so GIDSignIn.sharedInstance.signIn(with: config, presenting: self) is available. This is a temporary solution till we find working way.
Don't add new property named "GIDClientID" into the Info.plist of target project, use CLIENT_ID which is defined in GoogleService-Info.plist instead.
Find more details here:
https://stackoverflow.com/a/74897652/19683708
This changes in google sign is new. Also GIDSignIn.sharedInstance.signIn(with: config, presenting: self) is not available anymore. GIDSignIn.sharedInstance.signIn(withPresenting: presentingVC) replaced it. But I got same error. Hope to someone find an answer

Intellij plugin development print in console window

I am new to Intellij Idea plugin development. So I am developing a simple plugin to print a string value in a tool window(similar to console window)! There are less examples when I searched the web! I have a slight understanding about the Intellij action system but is unable to figure out how to register the necessary action in the plugin.xml to print the string in a tool window!
Following is my code
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
public class A extends AnAction {
#Override
public void actionPerformed(AnActionEvent e) {
String x="Hello how are you?";
}
}
How can I print String x in a tool window?
Console windows can't just exist on their own, they have to be tied to a tool window. Here's a quick example.
First create a ToolWindow for your plugin in XML:
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<toolWindow id="MyPlugin"
anchor="bottom"
icon="iconfile.png"
factoryClass="com.intellij.execution.dashboard.RunDashboardToolWindowFactory"></toolWindow>
</extensions>
Then in your action, you can grab a handle to that tool window and lazily create a console view, then add your text there:
ToolWindow toolWindow = ToolWindowManager.getInstance(e.getProject()).getToolWindow("MyPlugin");
ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(e.getProject()).getConsole();
Content content = toolWindow.getContentManager().getFactory().createContent(consoleView.getComponent(), "MyPlugin Output", false);
toolWindow.getContentManager().addContent(content);
consoleView.print("Hello from MyPlugin!", ConsoleViewContentType.NORMAL_OUTPUT);
A couple of notes:
Your new tool window may not be visible by default so you may need to activate it from the View -> Tool Windows menu.
We used RunDashboardToolWindowFactory to create our new tool window, so it will take on the layout of a run window. You can use any implementation of ToolWindowFactory (including your own custom class) in its place.
RunDashboardToolWindowFactory no longer exists in the lastest intellij-community codebase. The only reference I have is https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/tool_window
Actions should be registered this way (inside in plugin.xml) :
<actions>
<group id="MyPlugin.TopMenu"
text="_MyPlugin"
description="MyPlugin Toolbar Menu">
<add-to-group group-id="MainMenu" anchor="last"/>
<action id="MyAction"
class="actions.MyAction"
text="_MyAction"
description="MyAction"/>
</group>
</actions>
Also, make sure your action is inside a package, otherwise it might not be found/called.

Customize appsetings.json for user in ASP Core 1 app

My goal is to have appsettings.json file with production configurations and have possibility to costomize it for every developer, e.g. use local connection strings. So it does not similar to transform web.config mechanism, i don't want depends on bulid configuration. Can anyone provide solution for this goal?
In one of my past project we do so: we store all configure information in custom config.xml and parsed it into the custom structure. Web.config contains only server configaration. every developer has own copy of config files with his own data. Solution is that application use configuration files from path, that specified in environment path in windows via Environment.GetEnvironmentVariable("key").
Does anyone have idea better than my one?
This is how I manage configuration: see comments in the code
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json"); // this one has default configuration
// this file name is added to my gitignore so it won't get committed,
// I keep local dev configuration there
builder.AddJsonFile("appsettings.local.overrides.json", optional: true);
if (env.IsDevelopment())
{
// This reads the configuration keys from the secret store.
// if you need a more secure place for dev configuration use usersecrets
// For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
builder.AddUserSecrets();
}
// the order in which config sources is added is important, a source added later
// will override the same settings from a source added before
// environment variables is usually for production and therefore added last to give it higher priority
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}

Sharepoint Designer says: "The list of workflow actions on the server references an assembly that does not exist"

I successfully deploy my custom Action to the list of Actions available for use in my SharePoint Designer, but when opening an existing workflow, or creating a new one in the Designer, I get the message (and of course my custom action is not on the list of actions)
The list of workflow actions on the server references an assembly that
does not exist. Some actions will not be available. The assembly
strong name is {Actual Assembly strong name}. Contact your server
administrator for more information.
I checked the Strong Assembly name, Global Assembly Cache, package options, .ACTIONS file, web.config... Everything seems ok. Any new Ideas?
I am assuming the custom action is a farm deployed activity, which inherits from System.Workflow.ComponentModel.Activity (perhaps using subclass SequenceActivity, but really that doesn't matter)
I'm guessing that you haven't created the required ACTIONS file, which gets deployed to TEMPLATE\1033\Workflow
<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
<Actions Sequential="then" Parallel="and">
<Action Name="Description for SP Designer"
Assembly="$SharePoint.Project.AssemblyFullName$"
ClassName="AssemblyName.ClassName"
AppliesTo="all"
Category="SPD category"
UsesCurrentItem="true"
>
<RuleDesigner Sentence="Line as it appears in SPD workflow" />
<Parameters>
<Parameter Name="__ActivationProperties" Type="Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties, Microsoft.SharePoint" Direction="In" />
</Parameters>
</Action>
</Actions>
</WorkflowInfo>
SPD reads the list of activities from the ACTIONS files. Adding the file will get it into the menu. To actually add it to the workflow, you also need to authorize the custom workflow activity by class name.
To add the authorized type, I use a feature receiver with the following spwebmodification:
private SPWebConfigModification CreateWebConfigModification(string assembly, string assemblyNamespace)
{
return new SPWebConfigModification()
{
Type = (SPWebConfigModification.SPWebConfigModificationType)0,
Name = String.Format("authorizedType[#Assembly='{0}'][#Namespace='{1}'][#TypeName='*'][#Authorized='True']", (object)assembly, (object)assemblyNamespace),
Path = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes",
Owner = assemblyNamespace,
Sequence = 0U,
Value = String.Format("<authorizedType Assembly='{0}' Namespace='{1}' TypeName='*' Authorized='True' />", (object)assembly, (object)assemblyNamespace)
};
}
this will generate an SPWebConfigModification which can be used during install/uninstall.
Check you local admin privleges. This error comes up if you don't have local priveleges
create a new web and site collection and create a new a new workflow for the new site. you'll get the error message. don't save the work flow. and close the SPD.
reopen the designer and create a new work flow it'll solve the problem.

How to define default preferences (prefpane)

I've successuflly created a custom prefpane for my application (in thunderbird) and defined some preferences.
At the moment, the values in my prefpane are empty by default. However, when I do enter/select and save them, everything is good and they get written into the default database.
<preferences>
<preference id="myextension.settings.autosync_time"
name="myextension.settings.autosync_time"
type="int"/>
<preference id="myextension.settings.autosync_server"
name="myextension.settings.autosync_server"
type="string"/>
</preferences>
How can I predefine values to my preferences (eg. autosync_time = int(60) and autosync_server = string(dlc://mydlc.com) for my application ?
If you are packaging an extension, you put a JavaScript file with default preferences into the defaults/preferences directory:
pref("myextension.settings.autosync_time", 60);
pref("myextension.settings.autosync_server", "dlc://mydlc.com");
If you are packaging a XULRunner application or changing Thunderbird the same file goes into the defaults/prefs directory of the application.

Resources